Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initializing Amplitude SDK with user_id to prevent race conditions #5

Open
snaptravel-eng opened this issue May 20, 2022 · 0 comments

Comments

@snaptravel-eng
Copy link

I have a question about integrating the Amplitude SDK with GTM:
https://github.com/amplitude/GTM-Web-Demo

In the GTM demo, I see that the Amplitude SDK initialization is separate from setting the user_id from GTM. This can lead to race conditions where events are fired before the user_id is set.

I'm wondering if there's a way to set the user_id from GTM so that it's part of the Amplitude SDK initialization

amplitude.getInstance().init("API_KEY", userId); // initializes client with the given userId

https://developers.amplitude.com/docs/javascript#setting-user-id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant