Closed nafatrue closed 2 years ago
@nafatrue Since GA script will be lazyloaded, so the gtag outside Defer scope may not work until the script fully downloaded.
You may try:
<script>
Defer.js(['https://www.googletagmanager.com/gtag/js?id=XXXXX', 'gtag-js', 100, function() {
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'XXXXX');
});
</script>
@nafatrue BTW, did you get any error?
hi i'm trying to defer gtag Google Analytics 4 js script but no success here is my code
Defer.js('https://www.googletagmanager.com/gtag/js?id=XXXXX','gtag-js', 10); window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'XXXXX');