Skip to main content
Editing and Publishing Tutorials

Set up Google Analytics

Set up a Google Analytics data stream and get the embed code

  1. Use the following instructions to set up an account and/or property if needed: [GA4] Set up Analytics for a website.
  2. Use the option Add the Google tag directly to your web pages (under the heading Set up data collection for websites) to get the HTML code to add to your website. It should look like this, where your site's unique ID replaces G-XXXXXXXXXX.
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-XXXXXXXXXX');
</script>

Add the code to Brightspot

  1. Go to the Front-End tab on the Admin > Sites and Settings page.
  2. Scroll to the bottom of the page and find the Advanced section.
  3. Click the Advanced section name to open the section. The arrow on the right of the section title bar should point up.
  4. Scroll down further until you see the Custom Scripts and Styles field.
  5. Click + Add Custom Head Elements.
  6. In the resulting field set, set the Name to Google Analytics.
  7. Scroll past the Path Request Matcher area and find the Elements field.
  8. Click the dropdown under Elements and choose Script Element. A section titled "Script Element: Untitled" will open.
  9. In the Title field, enter Google Analytics Script.
  10. Change the Type to Link.
  11. Copy the contents of the src tag from the code snippet, https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX and paste it into the Script URL field.
  12. Turn on the Async? toggle.
  13. Click the + Add dropdown again and select Script Element. This will create another script on your page. We'll add the other component of the Google script here.
  14. Set the Title to Google Analytics Activation.
  15. Copy the code between the <script> tags of your Google Analytics installation code, and paste it into the Body field. In this tutorial, it should look like this:

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

  16. Click the Save button at the bottom of the page.

Data may take several hours to appear in your Google Analytics dashboard, though it usually appears within an hour of successful configuration.