Open williamrobertson13 opened 1 year ago
Hi @williamrobertson13, thank you for choosing Amplitude. We like hearing from our customers so we really appreciate sharing this with us. I'm more than happy to find the best path forward for you. Before anything else, I'd like to hear more.
but that isn't quite the same and we miss out on potentially useful insights
Can you elaborate on this point more? I'd also like to explore opportunities on how to improve our deferred initialization logic, even if end up moving forward with a different solution for you.
Hey @kevinpagtakhan! Thanks for the quick response. So to elaborate on the problem with deferred initialization - a lot of folks don't accept or reject consent to use tracking cookies when prompted with consent banners on websites. With the current solution of deferred initialization, a user could go to a site -> do all sorts of actions without ever accepting/rejecting consent -> leave the site and Amplitude won't ever initialize and log events. As one alternative solution, I suppose maybe you could add a pagehide
listener and initialize Amplitude with the transport type to beacon
and the identity storage to none
for this particular use case? AFAIK pagehide
isn't the most reliable though hence the custom Storage provider route we're experimenting with.
hey @williamrobertson13 you can set identityStorage to None on init, like this:
amplitude.init(apiKey, { identityStorage: 'none' });
This stores everything in memoryStorage, which is wiped when the user abandons the website. You can reinitialize like this once the user consents to cookies:
amplitude.init(apiKey, { identityStorage: 'cookie' });
hey @williamrobertson13 you can set identityStorage to None on init, like this:
amplitude.init(apiKey, { identityStorage: 'none' });
This stores everything in memoryStorage, which is wiped when the user abandons the website. You can reinitialize like this once the user consents to cookies:
amplitude.init(apiKey, { identityStorage: 'cookie' });
Hey, is it correct to call init
twice to change the indentityStorage
? Do you know if there is any helper to do that?
I'm wondering about the same thing as @RubenZx , we would like to achieve the following process (in order to maintain tracking across multiple apps on the same domain):
pageload: init with sessionStorage
consent: init with cookieStorage
revoke consent: init with sessionStorage again
I share the same interest. From what some of our testing has shown, custom plugins do not work after re-initialization.
Summary
The
cookieStorageProvider
property was removed in v2.0.0 of the Browser SDK, so this blocks us from being able to specify a custom storage provider for GDPR compliance purposes. It would be amazing if the SDK provided this type of functionality out of the box (e.g.switchIdentityStorage
) or added acustom
option toidentityStorage
so folks can provide custom storage providers again.Motivations
For GDPR compliance, we would like to track users using memory storage and then switch to cookies only after users have provided their consent to use tracking cookies. We were able to do this in
@amplitude/analytics-browser@v1.0.0
by creating a customStorage
instance (https://github.com/MystenLabs/sui/blob/main/apps/core/src/utils/persistableStorage.ts) and using that for thecookieStorageProvider
property. We're aware of the default recommended solution of deferring the initialization of Amplitude until users have provided consent, but that isn't quite the same and we miss out on potentially useful insights.