Skip to main content

I am using GTM to instrument Amplitude and have an issue I think many of you have bumped into. I am trying to track a user across different domains by passing the deviceid in the url.

 

However, I can't access the deviceid in the right amplitude instance from code in order to pass it in the url. Here's a reference to a description of the problem in an Amplitude Community forum: https://community.amplitude.com/data-instrumentation-57/cross-domain-tracking-typescript-1461?postid=8608#post8608

 

I'd be grateful for any help as this is going to be crucial for our implementation to work. Thanks! (ping @Esther Trapadoux)

@Linus Lennstrand thanks for this! Have you tried this option yet? Let me know if this works for you (or not), and we’ll keep digging into it.


@Linus Lennstrand thanks for this! Have you tried this option yet? Let me know if this works for you (or not), and we’ll keep digging into it.

Yes, we have absolutely tried that. The problem is exactly that we haven’t been able access the device id from the amplitude instance that has been initialised from GTM when trying to get it from code on the page.

 

When running amplitude.getDeviceId() (amplitude.options.deviceId is not available in Analytics Browser SDK) it returns undefined.


I have also tried the solution provided by @Alyssa Yu in 

however, it’s not working either. 


I’m sure there must be a way using the SDK, but if not you could perhaps read it directly from the amplitude browser cookie?


the name of the amplitude cookie is found in the instance using amplitude.getInstance()._cookieName 


Problem solved (solution described here)!


Reply