Examples of cross domain implementation with third party cookie

  • 9 September 2021
  • 8 replies
  • 1378 views

Badge

Hi all!

Amplitude newbie here so hoping to learn from someone who has done this before. We're trying to implement cross-(sub)domain tracking between our marketing site (think example.com) and web app (think portal.example.com). Right now we have Amplitude on both sites but the user histories are not stitched together, as if Amplitude can’t merge the IDs.

We are following the steps in the documentation https://help.amplitude.com/hc/en-us/articles/115003135607#h_f717e48c-460c-4a17-abd7-102327673798 but on step 2 we cannot use URL parameters because of the nature of the experience, only third party cookies would be viable. How can we implement a third party cookie that sends the device ID to the portal site so that, even if time passes between user visits the marketing sites and then converts, we can track it? Has anybody found a best practice to accomplish for subdomains in particular?

 

Thanks in advance!

 

Veronica

 

PS: reached out to support already but they don’t have any example implementation beyond the URL parameters solution which is here: https://developers.amplitude.com/docs/advanced-settings


8 replies

Userlevel 6
Badge +8

HI @Veronica !

 

Thanks for writing into Amplitude COmmunity! I believe we were speaking on the support ticket, did you get a chance to read through the information and resources I sent ? Regardless, I will reach out to our Engineers internally and I will see if they have an example or some other resources for you.

 

I will get back to you as soon as I hear word back from the Engineers!

Badge

HI @Veronica !

 

Thanks for writing into Amplitude COmmunity! I believe we were speaking on the support ticket, did you get a chance to read through the information and resources I sent ? Regardless, I will reach out to our Engineers internally and I will see if they have an example or some other resources for you.

 

I will get back to you as soon as I hear word back from the Engineers!

 Hi Denis! 

Yes I did check those links but they are more generic information about how 3rd party cookies work, which I was already familiar with. Would be great to get a better sense on how to actually pass the Amplitude  ID this way (like the example you have in the dev documentation with URL params).

 

Thanks for any additional help! I think it would be a good enrichment to the documentation.

Userlevel 6
Badge +8

Hi @Veronica ,

 

I completely agree, it would be good to have in the documentation! I have reached out to the Engineers and I will respond on this thread as soon as I have word from them :)

 

Kind Regards,
Denis

Userlevel 6
Badge +8

 HI @Veronica ,

 

Engineers are still looking into this but may I ask you about what is the “nature of the experience” that would preventing a usage of URL parameters? Engineers have said that third party cookies are not the most reliable way to send the device ID considering they can be blocked easily by any user/browser and their future is uncertain. If you can make URL parameters work, that would be much better. What is it specifically about the nature of the experience that doesn’t allow parameters? Thank you!

Badge

Hi Denis, we can’t pass URL parameters as there is a third party site in the middle of our CX.

Step 1: user lands on domain. We drop Amplitude ID.

Step 2: user lands on third party website after conversion event

Step 3: user returns on subdomain, where Amplitude is also implemented. We’d like the subdomain to detect the original Amplitude ID and merge the user sessions so we can track downstream events of the same user.

 

We are aware third party cookies are not very reliable, especially if a long time passes between step 2 and 3, but that’s the best we’ve got according to your documentation. Open to creative suggestions.

Userlevel 6
Badge +8

Hi Veronica, so are the other domains under the same, single website?  If that’s true for your use cases, then you shouldn’t need 3rd party cookies because the amplitude JS SDK uses a single cookie set for the top level domain to track users. Are you passing in any custom options to the SDK that might affect how it handles the domain?

Userlevel 6
Badge +9

Hi @Veronica I hope all is well. I noticed that there are still some open questions here and I wanted to check in. Were you able to make progress? Please let us know if you need any support. 😀

Hi @Veronica, I am an Amplitude Engineer from the SDK team. @Denis Holmes provides a good solution here:

Hi Veronica, so are the other domains under the same, single website?  If that’s true for your use cases, then you shouldn’t need 3rd party cookies because the amplitude JS SDK uses a single cookie set for the top level domain to track users. Are you passing in any custom options to the SDK that might affect how it handles the domain?

  1. Both Amplitude JS and TS SDK set cookies at the most top level domain which support cookies storage. So in your case:

We're trying to implement cross-(sub)domain tracking between our marketing site (think example.com) and web app (think portal.example.com). 

You don’t have to set up third-party cookies, the SDK will handle that by default

  1. If you are going to track for example “abc.com” and “xyz.com”, you will need to pass device ID to the these domains in order to track anonymous users 

We just released a new cookie guide page: https://www.docs.developers.amplitude.com/guides/cookies-consent-mgmt-guide/. Feel like that would be useful as well.

It’s highly recommended to migrate to TS SDK as JS SDK is in maintenance status and only receives bug fixes. To learn more about their differences.

 

Reply