Skip to content

Instantly share code, notes, and snippets.

@Dan0sz
Last active Jan 21, 2022
Embed
What would you like to do?
Use localStorage to store Google Analytics clientId
// Check if localStorage is present. It usually is.
if (window.localStorage) {
ga('create', 'UA-XXXXX-Y', {
'storage': 'none',
'clientId': localStorage.getItem('GA_CLIENT_ID_HASHED')
});
} else {
ga('create', 'UA-XXXXX-Y', 'auto');
}
ga('send', 'pageview');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment