Getting URL of the current page

#1

To help with providing a better experience for the user, it would be helpful to know the context of where they are on the host site by providing the initialize endpoint with the URL the user is currently on.

Is this possible, or can the current URL be retrieved by some other method?

1 Like
#2

+1 This would be really useful for the App I am working on

#3

Thanks @chris and @jonas!

#4

Hey @chris and @jonas :wave: so in the Submit flow for the end user, we actually post the referrer URL that the user was last on within the params of the webhook.

Using that URL you should be able to gather some more context about what the user is doing in the application?

However, you’re absolutely right, in the initialise method, we don’t have that context yet, unless your application is on the Messenger homescreen, in which case you will still be using the submit flow here, as it’s all user based interaction!

Hope that helps :+1:

#5

Thanks @jonny

Is this something that will be coming for the initialize method? As it will help to make the initial home screen app more contextual, rather than needing the user to take some action first to get the context.

#6

No decisions yet Chris but it’s something we’ve heard from several people so we’ll be strongly considering it.

1 Like
#7

+1 I would like to render content on the initial canvas that’s within the context of the page the user is on. is there a workaround for this? I have a live canvas but need to get the context without needing a user submit

#8

Hi @jonny / @jeff is the referrer available when using a live canvas on messenger home?
Also would be nice to have the user-agent and accept-language headers available

#9

@jonas so whenever the user submits anything (i.e. to prompt the live canvas to load) we will post back the referrer.

However, if the user doesn’t submit anything and you simply initialise the card with a live canvas, we won’t post that.

Once there is some amount of interaction, it will work though :slight_smile:

#10

@jonny thats a shame. would be nice to be able display content relevant to the current page without the user having to click anything. thanks

#11

ok no problem will add a button for now. thanks

#13

@jonny I’ve been experimenting with using the submit flow, I’m ok with the extra click now :slight_smile: . However I think there is still a bit of a problem with not having referrer available in the content flow, consider the following:

  1. User opens the messenger home on https://mysite.com/page1 and clicks on a button triggering the submit flow
  2. App returns a new canvas that is relevant to the https://mysite.com/page1. so far so good!
  3. user goes to https://mysite.com/otherpage. Original canvas that is relevant to https://mysite.com/page1 from step 2 is still displayed.

Thanks!

#14

@jonas, totally, that’s excellent feedback! I can really see how useful that will be and we’ll definitely take that into account as we look to work on the framework, thanks for that really helpful example! :tada:

#15

hey @jonny / @jeff, curious if there’s any update / decision on exposing what page the user is on to the initialise endpoint (for the messenger home screen) so we can contextualise our apps home screen?

#16

I’ll check with the team @chris and let you know. I know we’re adding more (and more consistent) context to all requests but I’m not sure about current page URL.

1 Like
#17

Hey @chris, we are currently working on that and should release something in next week or two. The context object will include referrer for two webhooks: fetching live card and submit.

We will not add referrer to initialise endpoint as it’s decoupled from any particular end user - it’s generic and the card being initialised will be shown to all end users on the homescreen. However, if you initialise live card, you will get referrer of every end user while fetching the canvas for this live card.

Is it helpful?

1 Like
#18

Are we only going to get the referrer or will we have the full User object? full user object would be really great for the live card. thanks

#19

@jonas We are also working on full user object, but not sure yet if we are going to release both of these things at once - it depends on how fast we move with the user object, don’t want to block releasing referrer for that. Let me get back to you in few days :slight_smile:

1 Like
#20

Hey folks, we’ve just released some updates to our context and user objects that will give you access to the current page URL of the end-user. We’ve also released some new components :wink:. Check out this post for more details and links to the docs.