1

I would like to know how and where to add this code to SharePoint and start tracking usage via Google Analytics. I've seen conflicting information about adding to the master page and . When I reupload to Master Pages and Page Layouts the changes are not shown. Can anyone help please?

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

  gtag('config', 'UA-xxxxx);
</script>

1 Answer 1

0

If you are using the classic pages, you should be able to add your script to the head tag of your masterpage and publish.

If you're using the modern pages, you might be able to use the SPfx extensions.

1
  • Got this working in the end - had to copy the masterpage and injected the code into the head tag., Thanks
    – Stephen
    Mar 13, 2018 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.