Solved

Can we set the options after initiating the SDK?


Badge

Hi,

We are using JavaScript SDK on our website. We want to enable attribution (utm, referrer etc.). After looking at the documentation, I see the options have to be enabled along with init command. Can we also enable these options after the init separately. We want do this because the SDK is placed on the web source code and we want to enable these options from GTM.

icon

Best answer by Denis Holmes 7 July 2021, 10:12

Hi @ram_manohar !

 

Thanks for writing into the Community! Always good to see people use it. :)

 

With regards to the options for the SDK, there would be no way to enable the options after the SDK initialisation. They would need to be passed as an argument when initialising the SDK. If you are wondering if the options can be turned off and on, I am not sure but I will ask the Amplitude Engineers and enquire!

 

However, another option would be to initialise a second SDK instance at some point and then put in the options. You could also try to pass a new SDK initialisation with the options and work with that while making the first initialisation null. It would depend on your architecture and while I am not too familiar with GTMs layout, I think a second instance of the SKD is better. If the two can communicate between them, one could send a ‘flag’ or message of some sort of when to initialise the second instance with the options. Would this be something possible for you to implement?

View original

2 replies

Userlevel 3
Badge +2

Hi @ram_manohar !

 

Thanks for writing into the Community! Always good to see people use it. :)

 

With regards to the options for the SDK, there would be no way to enable the options after the SDK initialisation. They would need to be passed as an argument when initialising the SDK. If you are wondering if the options can be turned off and on, I am not sure but I will ask the Amplitude Engineers and enquire!

 

However, another option would be to initialise a second SDK instance at some point and then put in the options. You could also try to pass a new SDK initialisation with the options and work with that while making the first initialisation null. It would depend on your architecture and while I am not too familiar with GTMs layout, I think a second instance of the SKD is better. If the two can communicate between them, one could send a ‘flag’ or message of some sort of when to initialise the second instance with the options. Would this be something possible for you to implement?

Badge

Thank you very much for your answer. I will check with our development team to know what is possible.

Reply