danyal14
danyal14

Reputation: 367

Google Analtyics gTag

Is it correct way of implementing Google Analytics?

<script async src="https://www.googletagmanager.com/gtag/js?id=UA-000000- 00"></script>

<script>

window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-000000-00');
gtag('config', 'UA-000000-00', { 'anonymize_ip': true, 'forceSSL': true, 'anonymize_ip': true });
gtag('config', 'UA-000000-00', {'page_title' : 'home', 'page_path': '/'});

Upvotes: 1

Views: 246

Answers (1)

Andreas
Andreas

Reputation: 23958

Reading the documents it seems you are missing the "event" and have placed the values in the config.
https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets

<script async src="https://www.googletagmanager.com/gtag/js?id=UA-000000- 00"></script>

<script>

window.dataLayer =  window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-000000-00');
gtag('config', 'UA-000000-00', {'metric1': 'anonymize_ip', 'metric2': 'forceSSL'});
gtag('config', 'UA-000000-00', {'metric3': 'page_title', 'metric4': 'page_path'});

gtag('event', 'send', {'anonymize_ip': true, 'forceSSL': true,'page_title': 'home', 'page_path': '/');

I deleted one of the duplicate anonymize_ip.

Upvotes: 1

Related Questions