Skip to main content
All CollectionsForms & IntegrationsThird-party client-side codes
Google Analytics 4 tracking code and custom events
Google Analytics 4 tracking code and custom events

Learn how to set up your GTM to track specific Doc events in GA4

Radovan avatar
Written by Radovan
Updated over 4 months ago

Adding a GA4 tracking code to your Turtl Doc(s) will send events, e.g. page views, to Google Analytics 4 when the user interacts with Turtl Doc. Once those events are in your GA4, they can support various processes.

Notes:

  • The default GA4 tracking code is available with all Turtl plans.

  • Custom events setup is available with either the Unlimited plan or Professional plan with the "Custom behavioral events" module added.

Prerequisites:

  • GA4 configuration tag. In the same way as it would for your website, the configuration tag acts as the bridge between your Turtl Docs and GA4 - collecting data and insights about user interactions, behavior, etc. You will need to insert GA4 "Measurement ID" inside this tag.

How do I get the tracking code?

In your GTM container, click "Admin" in the top menu, then select "Install Google Tag Manager".

Please copy both <head> and <body> scripts above and proceed to the next step.


What’s the process of getting the tracking code into Turtl

Once you have the previously mentioned <head> and <body> scripts, please send them to support@turtl.co and we will set it up as an extension for you, which can be toggled on/off on your Turtl Docs. You can also choose to apply this extension to all Turtl Docs automatically.


What events does the tracking code collect by default

By default, Google Tag Manager supports page view events.


Where do events appear in GA4

  1. Sign in to Google Analytics.

  2. From the left menu, select "Reports".

  3. On the left, click "Engagement" -> "Events".

Please refer to the Google Analytics Events report article for more details on where to find events.

Note: It may take up to 24 hours before you will see this data in GA4.


How can we customize the tracking code to send custom performance events to GA4

If you are on Turtl’s Unlimited or Professional plan and have purchased the "Custom Behavioural Events" module, our engineering team can customize the previously mentioned <head> and <body> scripts to send through additional events that aren’t captured within the standard script.

For these custom events to be seen, they need to be created by the customer in GA4.

Custom events table with variables

Below is the suggested list of events and variables. Variables in bold belong to all events, other variables are specific to only some events.

Event name

Variables

Notes

Chapter page turn

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

Surf page turn

Page turn

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

Immerse page turn

Read Doc 30 sec

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

Read Doc 1 minute

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

Read Doc 2 mins

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

Read Doc 3 mins

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

Read Doc 4 mins

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

Read Doc 5 mins

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

Read Doc 8 mins

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

Read Doc 10 mins

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

Enter chapter

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

Enter Immerse page(s)

Leave chapter

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

Leave immerse page(s)

Logo click

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

Contents menu click

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

Download the PDF version

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

PDF download button in the Contents menu

Open fullscreen

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

Link click

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

  • label (string)

  • destination (string)

Lead capture form submission

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string))

Personalization form submission

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

Poll submission

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

  • question (string)

  • response (string)

Share button click - email

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

  • share_button_location (string)

Share button location custom property specifies the location where the share button was clicked:

  • Toolbar

  • Immerse level widget

  • Back cover

Share button click - X

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

  • share_button_location (string)

Share button location custom property specifies the location where the share button was clicked:

  • Toolbar

  • Immerse level widget

  • Back cover

Share button click - Facebook

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

  • share_button_location (string)

Share button location custom property specifies the location where the share button was clicked:

  • Toolbar

  • Immerse level widget

  • Back cover

Share button click - Linkedin

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

  • share_button_location (string)

Share button location custom property specifies the location where the share button was clicked:

  • Toolbar

  • Immerse level widget

  • Back cover

Share button click - Xing

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

  • share_button_location (string)

Share button location custom property specifies the location where the share button was clicked:

  • Toolbar

  • Immerse level widget

  • Back cover

View chart

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string))

  • label (string)

  • source (string)

  • Open chart in zoom mode

View image

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

  • label (string)

  • source (string)

  • Open image in zoom mode

View map

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

  • label (string)

  • source (string)

  • Open the map in zoom mode

View PDF

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

  • label (string)

  • source (string)

  • Open PDF in zoom mode

Watch video

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

  • label (string)

  • source (string)

Listen to audio

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

  • label (string)

  • source (string)

View Matterport tour

  • doc_name (string)

  • doc_url (string)

  • workspace (string)

  • page_title (string)

  • label (string)

  • source (string)

Tip: Please contact our support team to share your ideas if you want to track something else.

1. Create a custom event trigger

  1. In your GTM container, navigate to "Triggers" in the left sidebar and click "New" to create a new Trigger.

  2. Name the Trigger, e.g. "Watch video". We recommend using the same name for the trigger and the Turtl event you want to track.

  3. Click on "Trigger Configuration".

    1. Trigger Type: Choose "Other" -> "Custom Event" as the Trigger type.

    2. Event Name: Copy the name of your custom event (e.g. "Watch video") from the table.

    3. This Trigger fires on: Choose "All Custom Events".

    4. Click "Save" to create the Trigger.

2. Create Variables

In order to capture additional data sent with the custom events, you have the option to create Variables.

  1. In your GTM container, navigate to "Variables" in the left sidebar and click "New" to create a new variable.

  2. Name the variable, e.g. "Page title".

  3. Click on "Variable Configuration".

    1. Variable Type: Choose "Page Variables" -> "Data Layer Variable".

    2. Data Layer Variable Name: Copy the name of the Variable from this table.

      Please create variables you find useful for the events you want to fire.

  4. Click "Save" to create the Variable.

3. Create a Tag for each custom event

Notes:

  1. In your GTM container, navigate to "Tags" in the left sidebar and click "New" to create a new Tag.

  2. Name the Tag, e.g. "Watch video".

  3. Click on "Tag Configuration".

    1. "Choose tag type"-> "Google Analytics" -> "Google Analytics: GA4 Event".

    2. Input your "Measurement ID": You can find the Measurement ID in your Google Analytics by going to "Admin" -> "Property Settings" > "Data collection and modification" > "Data Streams". Click on the relevant data stream and find "Measurement ID" (e.g.: G-XXXXXXXXXX) under Stream Details.

    3. Copy the relevant "Event name" from the table and paste it into the "Event Name" input field.

    4. Click "Event Parameters"-> "Add parameter".

    5. Click on the battery icon on the right-hand side of the "Value" field to add a parameter (variable) from the list.

    6. Insert a variable name under the "Event parameter" input field:

    7. Repeat for all Variables that apply to the event.

    8. Finally, add the trigger that corresponds to the event and click "Save".

4. Test the custom event

When you receive confirmation the custom tracking code has been added to your Doc(s), we recommend Previewing the setup in GTM. Enable GTM's "Preview" mode to test and debug your setup. This mode allows you to see if your custom event is firing correctly and if the associated tags are being triggered.

5. Publish your changes

  1. Before publishing, review your container to ensure everything is set up correctly.

  2. Click "Submit" to publish your changes. It may take a few minutes for the changes to take effect.


Where do the custom events appear in GA4

Note: It may take up to 24 hours before you will see this data in GA4.

Custom events appear alongside default events.

  1. Sign in to Google Analytics.

  2. From the left menu, select "Reports".

  3. On the left, click "Engagement" -> "Events".

Did this answer your question?