Integrate Google Analytics in your store

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

This guide assumes you are setting up a Google Analytics account with the G- v4 (minimum) codes.

Prerequisites

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 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

https://www.googletagmanager.com/gtag/js?id=G-4A8REPWQ43</a>">

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

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

To do this, within your Salesforce Org, 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 Block 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 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

Terms

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 tag.

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".

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.