Thread tagged as: Discussion

New Google Analytics Content Template

Work is progressing very well on my new site, and I've just integrated the new Google Analytics Global Site Tag tracking code.

This differs slightly from Universal Analytics and the default template that you'll find in the templates/content folder, so I thought I'd post it here in case somebody needs it. I'm sure in time the Perch team will add it to the default package.

<script async src="<perch:content id="ga_code" type="text" label="Tracking Code" help="UA-XXXXX-X" />"></script>
    window.dataLayer = window.dataLayer || [];
    function gtag() { dataLayer.push(arguments); }
    gtag('js', new Date());
    gtag('config', '<perch:content id="ga_code" type="text" />');
Robert Carter

Robert Carter 0 points

  • 3 years ago