Tracking Template Checker / Script

Table of Contents

This script is designed to help Google Ads users review tracking templates across various entities, including campaigns, keywords, video ads, and more. It provides a comprehensive overview of the tracking templates utilized within your account.

Installation Steps

  1. Log into your Google Ads account.
  2. Navigate to ‘Tools & Settings’ (represented by a wrench icon) on the top menu bar.
  3. Under ‘Bulk Actions’, select ‘Scripts’.
  4. Click the blue ‘+’ button to create a new script.
  5. In the script editor, clear any default code and paste the following script:
/**
 * Google Ads Script: Enhanced <a href="https://clickpatrol.com/knowledge-base/i-have-issues-with-tracking-templates/">Tracking Template</a> Checker
 
Description:
This script is designed for Google Ads accounts to review tracking templates across various entity types such as campaigns, keywords, video ads, etc. Upon execution, it provides an overview of the tracking templates utilized by these entities.

Installation:
1. Log into your Google Ads account.
2. Navigate to 'Tools & Settings' (typically represented by a wrench icon) on the top menu bar.
3. Under 'Bulk Actions', find 'Scripts' and click on it.
4. Click on the blue '+' button to create a new script.
5. In the script editor, clear any default code (if present) and paste this script.
6. Click 'Save' to store the script.

Usage:
After <a href="https://clickpatrol.com/knowledge-base/what-are-budget-reallocations-on-clickpatrol/">saving</a> the script:
1. Click the 'Preview' button (usually an eye icon) in the script editor to run it in preview mode. This will execute the script without making changes, allowing you to detect any issues.
2. Once previewed and satisfied, click the 'Run' button to execute the script.
3. After the script executes, navigate to the 'Log' (usually represented by a notepad icon) to view the results. Here, you'll see the tracking templates used by various entities in your Google Ads account.

 * Author: Bernt Muurling
 * Updated by: Taskforce <a href="https://clickpatrol.com/agency/">Agency</a> & ClickPatrol
 * Version: 1.1
 */

// Entry point function
function main() {
  try {
    checkTrackingTemplates();
  } catch (e) {
    Logger.log("An error occurred: " + e.message);
  }
}

// Function to check tracking templates for various entity types
function checkTrackingTemplates() {
  var entityTypes = [
    { level: 'Campaign', selector: AdsApp.campaigns().withCondition('Status = ENABLED'), getUrlsMethod: entity => entity.urls() },
    { level: 'Keyword', selector: AdsApp.keywords().withCondition('Status = ENABLED'), getUrlsMethod: entity => entity.urls() },
    { level: 'VideoAd', selector: AdsApp.videoAds().withCondition('Status = ENABLED'), getUrlsMethod: entity => entity.urls() },
    { level: 'Ad', selector: AdsApp.ads().withCondition('Status = ENABLED'), getUrlsMethod: entity => entity.urls() },
    { level: 'AdGroup', selector: AdsApp.adGroups().withCondition('Status = ENABLED'), getUrlsMethod: entity => entity.urls() }
  ];

  entityTypes.forEach(entityType => {
    processEntities(entityType);
  });
}

// Process each entity type and log tracking templates
function processEntities(entityType) {
  var iterator = entityType.selector.get();
  while (iterator.hasNext()) {
    var entity = iterator.next();
    var urlsMethodInstance = entityType.getUrlsMethod(entity);
    var trackingTemplate = urlsMethodInstance.getTrackingTemplate();

    if (trackingTemplate) {
      var entityIdentifier = (typeof entity.getName === 'function') ? entity.getName() : entity.getId();
      Logger.log(entityType.level + ' "' + entityIdentifier + '" uses <a href="https://clickpatrol.com/knowledge-base/i-have-issues-with-tracking-templates/">tracking template</a>: ' + trackingTemplate);
    }
  }
}

Click ‘Save’ to store the script.

Usage Instructions

  1. Preview the Script: Click the ‘Preview’ button (eye icon) in the script editor to run it in preview mode. This executes the script without making changes, allowing you to detect any issues.
  2. Run the Script: Once satisfied with the preview, click the ‘Run’ button to execute the script.
  3. View the Results: After execution, navigate to the ‘Log’ (notepad icon) to view the results. Here, you’ll see the tracking templates used by various entities in your Google Ads account.

Benefits

This script simplifies the process of reviewing tracking templates across multiple entities in your Google Ads account, saving time and ensuring consistency in your tracking setup.

Abisola

Meet Abisola! As the content manager at ClickPatrol, she’s the go-to expert on all things fake traffic. From bot clicks to ad fraud, Abisola knows how to spot, stop, and educate others about the sneaky tactics that inflate numbers but don’t bring real results.

ClickPatrol © 2025. All rights reserved. - Built in the Netherlands. Trusted across all the world.
* For dutch registerd companies excluding VAT