# Contextual leaderboards on Facebook Instant

**URL:** <https://forum.defold.com/t/contextual-leaderboards-on-facebook-instant/44989>\
**Category:** The Defoldmine\
**Created:** [March 1, 2019, 4:09pm UTC](https://forum.defold.com/t/contextual-leaderboards-on-facebook-instant/44989 "2019-03-01T16:09:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [March 1, 2019, 4:09pm UTC](https://forum.defold.com/t/contextual-leaderboards-on-facebook-instant/44989/1 "2019-03-01T16:09:50Z")

</div>

I’ve got this working and wanted to share a couple of gotchas I had.

To load and save contextual scores the leaderboard name and context needs to be concatenated for it to work, like this:

```
local context_id, context_type = fbinstant.get_context()
if context_id then
    local name = "Leaderboard Name"
    local name_and_context = name .. "." .. context_id	
    fbinstant.set_leaderboard_score( name_and_context, score, "", on_set_leaderboard_score )
end

```

This is from the docs:

### fbinstant.set\_leaderboard\_score(name, score, extra\_data, callback)

Note that the parameter `extra_data` is required fore the score to be saved (it can’t be nil).

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [March 1, 2019, 4:59pm UTC](https://forum.defold.com/t/contextual-leaderboards-on-facebook-instant/44989/2 "2019-03-01T16:59:32Z")

</div>

Hmm, did you get an error when it was nil?

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [March 1, 2019, 8:34pm UTC](https://forum.defold.com/t/contextual-leaderboards-on-facebook-instant/44989/3 "2019-03-01T20:34:23Z")

</div>

Locally no, and when testing on Facebook Instant I get nothing in the browser output window (at all). It was a little tricky troubleshooting because of this!

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [March 1, 2019, 9:00pm UTC](https://forum.defold.com/t/contextual-leaderboards-on-facebook-instant/44989/4 "2019-03-01T21:00:57Z")

</div>

Please create a ticket on the GitHub page for the extension. I’d like to add a check for this parameter.

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [March 1, 2019, 9:28pm UTC](https://forum.defold.com/t/contextual-leaderboards-on-facebook-instant/44989/5 "2019-03-01T21:28:09Z")

</div>

> [@britzl](#):
>
> Please create a ticket on the GitHub page for the extension

Done! [set\_leaderboard\_score fails if extra\_data is omitted · Issue #58 · defold/extension-fbinstant · GitHub](https://github.com/defold/extension-fbinstant/issues/58)
