Add Google Analytics Tag in Google Tag Manager

Prev Next

This guide aims to explain how to add a Google Analytics Tag in Google Tag Manager. In this guide, you can find details about:

Set up Google Tag Manager 

  1. Go to the Google Tag Manager website and sign in with your Google account.

  2. Create a new Google Tag Manager account for your website/application if you have not already.

  3. Follow the on-screen instructions to set up your web-container. A container is a snippet of code that needs to be added to your website/application.

Add the Google Tag Manager code to your website/application

  1. Once you create the container, you will receive a GTM container code snippet.

  2. Copy the entire code snippet provided.

  3. Paste the code snippet into the "<head>" section of your website's HTML code. This should be added before closing the "</head>" tag.

  4. Save the changes and publish your website/application.

Set up a Google Analytics Tag in Google Tag Manager

  1. Go back to the Google Tag Manager interface.

  2. Click on the container's name to access it.

  3. Click on the Tags option in the left sidebar menu.

  4. Click on the New button to create a new tag.

  5. Give your tag a descriptive name, such as "Google Analytics - Widget Click Event."

  6. Choose the tag type. Select the "Google Analytics: GA4 Configuration" option for Google Analytics.

  7. Configure the tag by specifying the Measurement ID of your Google Analytics property. You can find the Measurement ID in your Google Analytics account under Data Streams >Web Stream details. 

  8. Choose the appropriate track type based on your requirements, such as "Event" for tracking widget clicks.

  9. Set the tag firing option under "Advanced Settings" to once per page. 

  10. Save the tag.

Create a trigger for the Tag

  1. Click on Triggers in the left sidebar menu.

  2. Click on the New button to create a new trigger.

  3. Give your trigger a descriptive name, such as "Widget Click Trigger."

  4. Select the trigger to fire on “Some Clicks”.

  5. Choose the Click Element trigger type, the condition “matches CSS selector,” and the value “.container__CompanyIcon-sc-qtelua-5.dmnmBT”. 

  6. Save the trigger.

Preview and debug

  1. In the Google Tag Manager interface, click the Preview button at the top-right corner to enable preview mode.

  2. Open your website/application in a separate browser tab or window.

  3. With the preview mode enabled, any changes you make in Google Tag Manager will be visible in the preview pane.

  4. Navigate to the page where the widget is located and interact with the widget to trigger the event you want to track.

  5. In the preview pane, you will see the tags and triggers firing and the associated data being sent to Google Analytics.

  6. Use the debug information provided to ensure the tag is firing correctly and capturing the desired data. If any issues are identified, you can return to Google Tag Manager to make the necessary tag or trigger configuration adjustments.

  7. Repeat the preview and debug process until you are satisfied with the tracking implementation.

Publish changes in Google Tag Manager

  1. Once you create the tag and trigger, click the Submit button in the top-right corner of the Google Tag Manager interface.

  2. Provide a version name and description for the changes you made.

  3. Click the Publish button to publish the changes.