Add Your Google Analytics Code

This article is intended for advanced users and our partners as it requires advanced web development or Salesforce admin or programming knowledge. While the functionality is part of StoreConnect, we do not provide end user assistance to implement it beyond our help documentation. If you need help or are unsure on how to do this, you can hire one of our StoreConnect partners.

Google Analytics, “allows you to track and understand your customer’s behaviour, user experience, online content, device functionality and more.”

In July 2023 Google Analytics will no longer support the old UA-123456 codes and you must use the new Google Analytics v4 codes which look like G-123456. This guide assumes you are setting up a new Google Analytics account with the new G- v4 codes.


How to install the Google Analytics code

Once you have created your Google Analytics 4 property and data stream, you are required to, “copy and paste this code as the first item into the <head>1 tag of every web page that you want to track.”

This code looks something like the following, yours will have a different value in place of G-4A8REPWQ43

<script async src=""></script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-4A8REPWQ43');

To do this, within your Salesforce Org2, install your Google Analytics code into the Head Content section as detailed on your Store.

If you have never created one before, you will to create a new Content Block3 using the +New Content Block option. For best practice, refer to, Adding Custom Javascript, CSS, Body and Head Content Scripts when creating a new Content Block for your <head> content.

If you already have Google Analytics installed and are not sure which Content Block it is contained in, remember you can always use Salesforce Search to find it. Simply put your old code (perhaps UA-123456) into the search bar at the top of your Salesforce instance, and select “Content Blocks” instead of “All” to search for where your old code was stored, then you can edit this content block to replace the old code with the new code.

Note: Once you have added the code, it can take up to 48 hours for Google to start reporting that it is receiving data.

If you are installing other tracking codes such as Facebook Pixel, you will need to add all the tracking codes into the same Content Block.

Learn more about the Content Management section of the StoreConnect Config app



  1. <head> tag: Used to contain metadata such as the title of the page, its description, and any relevant keywords. Scripts (code), links to scripts and CSS files (for page styling) may also be contained in the <head> tag. 

  2. Salesforce Org: The virtual space provided to an individual customer of Salesforce. It includes all of your data, records, etc and applications. A Salesforce Org, or “Org” for short is an abbreviation of “organisation”. 

  3. Content Block: Content Blocks are used to place content on your Pages and Articles. There are two types of Content Blocks 1) A Container Content Block, and 2) A Template Content Block. 


Back to Documentation