How can we help?

How to Install the Google Tag (gtag.js)?

01/06/2025

Installing the Google Tag (gtag.js)

This guide explains how to install the Google Tag (gtag.js).

It is important to understand that the Google Tag is separate from the ClickSambo tracking code.

ClickSambo's Code: This is your security guard. Its purpose is to monitor your website traffic and block click fraud.

Google's Tag (gtag.js): This is your business analyst. Its purpose is to send data to Google Analytics (for visitor stats) and Google Ads (for conversion tracking and remarketing).

If you use Google's advertising or analytics services, you will need to have both the ClickSambo codes and the Google Tag installed on your website.

Step 1: Get Your Google Tag Snippet

First, find and copy your unique Google Tag from your Google Analytics or Google Ads account.

Log in to your Google Analytics 4 or Google Ads account.

Find the installation instructions for your tag.

In Google Analytics 4, this is typically under Admin > Data Streams > Select your stream > View tag instructions.

In Google Ads, it's often under Goals > Conversions > Select a conversion action > Tag setup > Install manually.

Copy the entire JavaScript gtag.js snippet provided by Google. It will look similar to this, with your unique TAG_ID:

  • <script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
    
      gtag('config', 'TAG_ID');
    </script>
    HTML
    <script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
    
      gtag('config', 'TAG_ID');
    </script>

Step 2: Add the Google Tag to Your Website

This tag must be present on every page of your website to work correctly.

Edit your website's main theme or header template file.

Paste the copied gtag.js snippet into the <head> section of your website's HTML, ideally just after the opening <head> tag.

Save the changes to your template and publish your website.

Step 3: Verify the Installation

After adding the code, confirm it's working:

Check Real-time Reports: Log in to your Google Analytics account and look at the "Realtime" report. Visit your website in a separate tab, and you should see your visit register within a few moments.

Use Google Tag Assistant: Use Google's free "Tag Assistant Companion" Chrome extension to verify that your Google Tag is found and firing correctly on the page.

Important Considerations

Are you using Google Tag Manager (GTM)?
If you already use GTM, do not follow this guide. You should deploy Google tags (like the GA4 Configuration tag) from within the GTM interface instead of adding gtag.js directly to your site's code.

Always Refer to Google's Official Guides
Google frequently updates its products. For the most accurate and up-to-date instructions, always consult the official documentation for Google Analytics 4 or Google Ads.

Platform-Specific Instructions
The method for adding code to your site's <head> section varies depending on your website platform (e.g., WordPress, Shopify, Wix). Please consult your platform's specific help guides for detailed instructions.

Did this answer your question?
Customise Consent Preferences
Cookies

CookieConsentIntro

CookieConsentNecessary

CookieConsentThirdParty

CookieConsentChoice

Show More
Cookies Necessary
Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

Cookies Functional

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

Cookies Analytics

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

Cookies Performance

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

Cookies Advertisement

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

Cookies Uncategorised

Other uncategorised cookies are those that are being analysed and have not been classified into a category as yet.