How To Add Google Analytics 4 To Squarespace

Google analytics squarespace

There are different ways you can install Google Analytics 4 (GA4). You can use Squarespace’s built-in Google Analytics integration, you can use the ‘Code Injection’ feature to add Google Tag Manager, or you can use a combination of both. To learn more about the options and walk-through the configuration steps, you can watch this tutorial:

Installing Google Analytics 4 (GA4) with Google Tag Manager

If you are selling products on your Squarespace site and choose to install Google Analytics using only Google Tag Manager (and not a combination of Google Tag Manager and the built-in integration covered in the tutorial above), then you can collect limited details about transactions.

First, you will need to ensure that your Google Tag Manager container code has been added to Squarespace in ‘Code Injection’ (in the ‘Header’ section).

You will then need to add the following code to the ‘Order Confirmation Page’ section of your ‘Code Injection’ (by navigating to ‘Settings’, then ‘Advanced’, and choosing ‘Code Injection’):

You will need to update the value defined for ‘currency’ to reflect the currency used for your Squarespace store. Then you will need to configure variables, a trigger, and a tag in Google Tag Manager.

Variables

Create the following user-defined variables:

  1. Name: Ecommerce Transaction ID
    • Type: Data Layer Variable

    • Variable Name: ecommerce.transaction_id
  2. Name: Ecommerce Value
    • Type: Data Layer Variable

    • Variable Name: ecommerce.value
  3. Name: Ecommerce Currency
    • Type: Data Layer Variable

    • Variable Name: ecommerce.currency

Trigger

Create the following trigger:

  • Name: Purchase
    • Type: Custom Event

    • Event Name: purchase

Tag

Create the following tag:

  • Name: Google Analytics | GA4 | Purchase
    • Tag Type: GA4 Event

    • Event Name: purchase
    • Parameters (name and value):
      • transaction_id - {{Ecommerce Transaction ID}}

      • value - {{Ecommerce Value}}
      • currency - {{Ecommerce Currency}}
    • Trigger: Purchase

Comments