Skip to main content
Inspiring
May 4, 2020
Answered

In RH2019, new ui, parse error when trying to configure Google Analytics with my RH project

  • May 4, 2020
  • 2 replies
  • 1101 views

I have added the following code to the header of the master page:

 

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-000000000-0" ></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'UA-000000000-0');

</script>

 

where UA-000000000-0 is my Google Analytics Tracking ID.

 

And Robohelp is giving me a parse error for the first line of the script saying invalid character s and underlining the s of the src. I tried adding it this way 

 

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

 

(as I found a website that seemed to suggest that you add the async at the end) but then got Invalid character > underlining the > next to async. 

 

I got this code from the Google Analytics website.

 

 

    This topic has been closed for replies.
    Correct answer Amebr

    I think it's actually the async bit. Try changing to: 

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

     

     

    2 replies

    AmebrCommunity ExpertCorrect answer
    Community Expert
    May 5, 2020

    I think it's actually the async bit. Try changing to: 

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

     

     

    Inspiring
    May 5, 2020

    Thank you very much Amebr, that worked!

    Peter Grainge
    Community Expert
    Community Expert
    May 4, 2020

    Try adding a forward slash after the closing double quote marks. I had something similar with Google Fonts.

     

    Use the menu (bottom right) to mark the Best Answer or Highlight particularly useful replies. Found the answer elsewhere? Share it here.