brainy-london-213
01/17/2022, 11:09 AMelegant-eve-85294
sticky-night-20812
01/17/2022, 11:14 AMelegant-eve-85294
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="<https://www.googletagmanager.com/gtag/js?id=UA-XXX>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXX');
</script>
To be run per page change
<script>
function getUserid(){
try {
var studioUser = localStorage.getItem('studio_user');
if(studioUser) return;
var user = JSON.parse(localStorage.getItem('user'));
var sid = user._sid;
var recIndex = sid.indexOf("rec");
var recId;
if (recIndex >= 0) {
recId = sid.substr(recIndex);
}
return recId;
} catch (e) {
}
}
var userId = getUserid();
var config = {
'page_path': window.location.pathname
};
if(userId){
gtag('set', {'user_id': userId})
}
gtag('config', 'UA-XXX', config);
</script>elegant-eve-85294
gifted-leather-56422
01/18/2022, 2:42 PMgifted-leather-56422
01/18/2022, 2:45 PMgifted-leather-56422
01/18/2022, 2:46 PMelegant-eve-85294
sticky-night-20812
01/18/2022, 3:47 PMgifted-leather-56422
01/18/2022, 4:06 PMThis includes avoiding the use of impermissible personally identifiable information, and providing appropriate notice of your use of identifiers in your Privacy Policy. Your user ID must not contain information that a third party could use to determine a user's identity.sticky-night-20812
01/18/2022, 4:36 PMgifted-leather-56422
01/18/2022, 4:39 PMsticky-night-20812
01/18/2022, 4:41 PMrec_abc123 which cannot simply be translated into an identifiable information like an email or name.sticky-night-20812
01/18/2022, 4:46 PMpage_path: window.location.pathname for GA4, as far as I understand, it should be automatically done by GA. Did you run into any issue?elegant-eve-85294
sticky-night-20812
01/18/2022, 5:01 PMgifted-leather-56422
01/18/2022, 5:01 PMsticky-night-20812
01/18/2022, 5:02 PMgifted-leather-56422
01/18/2022, 5:13 PM