How to Install a Custom Script Tag Using Google Tag Manager (GTM)

Last updated: June 6, 2025

Overview

This article provides step-by-step instructions for implementing a custom <script> tag on a website using Google Tag Manager. The focus is on executing the script only on a designated URL.


  1. Accessing Google Tag Manager

    1. Navigate to: https://tagmanager.google.com

    2. Log in with your credentials

    3. Select the correct GTM container for your website

  2. Creating a New Custom HTML Tag

    1. In GTM, go to 'Tags' in the left-hand menu.

    2. Click 'New' to create a tag.

    3. Name the tag (e.g., 'Custom Script for Checkout Page').

    4. Under 'Tag Configuration', choose 'Custom HTML'.

    5. Paste your script code.

Example:

<script>
console.log('This script runs only on the checkout page.');
</script>

  1. Configuring Head-Like Behaviour

    1. Check 'Support document.write' if needed

    2. Under 'Advanced Settings'

    3. Set 'Tag firing options' to 'Once per page'

    4. Assign a high 'Tag firing priority' (e.g., 999)

Note: These steps simulate <head> loading behavior since GTM inserts scripts in the <body> by default.

  1. Creating a Trigger for a Specific URL

    1. In 'Triggering', click to add a new trigger.

    2. Select 'Page View' as the type.

    3. Choose 'Some Page Views'.

    4. Define the condition:

      1. Variable: Page URL

      2. Condition: equals

      3. Value: https://yourdomain.com/specific-path

  2. Saving and Publishing the Tag

    1. Click 'Save' after assigning the trigger

    2. In the workspace, click 'Submit'

    3. Optionally name and describe the version

    4. Click 'Publish' to activate

  3. Verification Methods

    1. Use the Google Tag Assistant extension.

    2. Check the 'Page Source' to confirm script presence.

    3. Use the browser's Developer Console for log inspection.


Tips for Success:

Need Assistance?
Contact our Support team if you have any questions or issues!