{"title":"Integrate Google Analytics in your store","slug":"add-your-google-analytics-code","url":"https://support.storeconnect.com/articles/add-your-google-analytics-code","url_markdown":"https://support.storeconnect.com/articles/add-your-google-analytics-code.md","subtitle":null,"summary":"Install your Google Analytics 4 tracking code into the Head Content block on your store record so every page is tracked, including how to find and replace old UA codes.","type":"Help_Documentation","video_url":"","keywords":"google analytics, google analytics 4, GA4, tracking code, analytics integration, head content, content block, store tracking, gtag, UA code migration, website analytics, javascript tracking","last_modified":"2026-08-21T07:12:35+0000","body_markdown":"Google Analytics, \"allows you to track and understand your customer's behaviour, user experience, online content, device functionality and more.\"\n\nThis guide assumes you are setting up a Google Analytics account with the `G-` v4 (minimum) codes.\n\n## Prerequisites\n\n-   You will need a Google Analytics account.\n-   You will also need to create your create a *Google Analytics 4 property* account and code by following the [Google Analytics guide for Salesforce (Demandware)](https://support.google.com/analytics/answer/10447272#salesforce\u0026zippy=%2Csalesforcedemandware).\n\n## Related help documents\n\n-   [Adding Custom Javascript, CSS, Body and Head Content Scripts](adding-custom-javascript-css-and-head-content)\n-   [Add your Facebook Pixel code](add-your-facebook-pixel-code)\n\n## How to install the Google Analytics code\n\nOnce 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.\"\n\nThis code looks something like the following, yours will have a different value in place of `G-4A8REPWQ43`\n\n```\nhttps://www.googletagmanager.com/gtag/js?id=G-4A8REPWQ43\u003c/a\u003e\"\u003e\n\n  window.dataLayer = window.dataLayer || [];\n  function gtag(){dataLayer.push(arguments);}\n  gtag('js', new Date());\n\n  gtag('config', 'G-4A8REPWQ43');\n```\n\nTo do this, within your **Salesforce Org**, install your Google Analytics code into the [Head Content](content-management) section as detailed on your Store.\n\nIf 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](adding-custom-javascript-css-and-head-content) when creating a new Content Block for your  content.\n\nIf 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.\n\nNote: Once you have added the code, it can take up to 48 hours for Google to start reporting that it is receiving data.\n\nIf you are installing other tracking codes such as [Facebook Pixel](add-your-facebook-pixel-code), you will need to add all the tracking codes into the same Content Block.\n\nLearn more about the [Content management](content-management) section of the StoreConnect Config app\n\n## Terms\n\n**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.\n\n**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\".\n\n**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."}