Multiple installations of Global site tag (gtag.js) detected in Gatsby application

Viewed 6892

I have Google Analytics code set up in my gatsby application.

<script>
    var gaId = "UA-xxxxxxxx-1";
    var JSLink = "https://www.googletagmanager.com/gtag/js?id=" + gaId;
    var JSElement = document.createElement('script');
    JSElement.src = JSLink;
    document.getElementsByTagName('head')[0].appendChild(JSElement);


    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments)}
    gtag('js', new Date());

    gtag('config', gaId);

</script>

When I checked the site with Google Tag Assistant, it says there are multiple installations of the tracking code.

How can I get rid of duplication installations of Global site tag? What recommendation for set up Google Analytics in React app?

enter image description here

enter image description here

1 Answers

Connect all your properties (Analytics, Google Ads) through google tag manager and include tag manager code to your site. It will be solve the problem.

Related