Google Ads Script: Enhanced Tracking Template Checker

Abisola Tanzako | Dec 14, 2023

Google Ads Script: Enhanced Tracking Template Checker by Bernt Muurling

This script is designed for Google Ads accounts, to help review tracking templates across various entity types such as campaigns, keywords, video ads, etc.

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 then paste this script.

6. Click ‘Save’ to store the script.

Usage:

After saving 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.

 

Start copying from the next line

/**
 * Google Ads Script: Enhanced Tracking Template 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 saving 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 Agency & 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 tracking template: ' + trackingTemplate);
    }
  }
}

 

End copying here

This script is easy to use and saves you a ton of time reviewing tracking templates across various entities simultaneously.

ClickPatrol © 2024. All rights reserved.
* For dutch registerd companies excluding VAT