Infinity Campus

Google Ads tagging

Written by Infinity | Nov 23, 2026, 1:05:03 AM

Set up Google Ads tagging to report your paid search activity correctly. You can set it up yourself in Google Ads, or let Infinity add the scripts and tracking template for you in the Infinity Platform. This guide covers both options, so you can choose the one that suits your account.

Option 1: set up Google Ads tagging with custom ValueTrack parameters

Follow this option if you want to tag at MCC level, don't want to connect your Google Ads account to Infinity, or prefer to manage the scripts yourself. You set it up in Google Ads with scripts and an account-level tracking template. If you would rather Infinity set this up for you, follow Option 2 below instead.

For the best tagging experience, set this up with custom ValueTrack parameters within Google Ads. The steps below use Google Ads scripts to make sure every campaign and ad group has custom ValueTrack parameters with its Campaign and Ad Group names. Infinity's tracking template then uses those names, so your paid search activity is tracked in Infinity.

Step 1: open the scripts page

The steps below follow the latest Google Ads interface, and they complete Google Ads tagging for every campaign and ad group.

  1. In Google Ads, go to Tools > Bulk Actions > Scripts.

Step 2: create a new script

  1. Click the blue + button and select New Script.

Step 3: name the script

  1. At the top left, set a name for the script so you know what it does, for example Sync Custom Value Parameters.

Step 4: authorise the script

  1. For the script to change your custom parameters, you need to authorise it using your Google Account. You should see a yellow bar on the screen. Click Authorise and follow the steps in the pop-up window.

Step 5: add the campaign script

  1. In the main editor window, replace all the content with the script below.

This part of the script looks at campaigns. It runs a search query on all enabled campaigns, creates a CSV with the campaign name and the custom parameters, and then uses the bulk updater to apply the changes. The Google Ads script only returns standard campaigns, so to update other campaigns, the script searches for the data it needs and triggers a bulk CSV upload to make the changes.

JavaScript
function updateCampaigns(){
  // Query to get all enabled campaigns
  const campaigns = AdsApp.search(`
    SELECT
      campaign.id,
      campaign.name,
      campaign.url_custom_parameters
    FROM campaign
    WHERE campaign.status = 'ENABLED'
  `);

  // Start a new bulk upload with the required headings.
  const campaignBulkUpload = AdsApp.bulkUploads().newCsvUpload(['Campaign', 'Campaign ID', 'Custom parameter'])

  // Iterate over all available campaigns until we've seen them all.
  while (campaigns.hasNext()) {
    // Grab the next campaign on the list and any existing Custom Parameters
    const { campaign } = campaigns.next();
    const paramValue = encodeURIComponent(campaign.name).replaceAll('%2B', '+');

    // Container to hold the individual parameters that we'll join together later.
    const customParamStringParts = [];

    // Get the list of custom parameters if there are any, or default to an empty list.
    const customParams = campaign.urlCustomParameters || [];

    // Check to see if we have an existing paramter for campaign
    const existingParam = customParams.find((param) => param.key === 'campaign');
    if (existingParam) {
      // If the values are the same, skip to the next one.
      if (existingParam.value === paramValue) {
        continue;
      }

      // Otherwise, set the updated value against the existing parameter
      existingParam.value = paramValue;
    } else {
      customParams.push({ key: 'campaign', value: paramValue });
    }

    for (const param of customParams) {
      // Add the parameter to the container
      customParamStringParts.push(`{_${param.key}}=${param.value}`);
    }

    campaignBulkUpload.append({
      "Campaign": campaign.name,
      "Campaign ID": campaign.id,
      // Joins the parameters together, separated by a semi-colon
      "Custom parameter": customParamStringParts.join('; ')
    });
  }

  // Trigger the bullk upload. In preview, this will trigger an upload preview.
  // Go to Tools and Settings > Bulk Actions > Uploads to see the results.
  campaignBulkUpload.apply();
}

Save this section of the script as Campaign Bulk Upload.gs.

Step 6: add the ad group script

Click the blue + icon to open a new script window, then copy and paste the text below. This part of the script relates to ad groups. It cycles through all the active ad groups and makes sure the custom parameters are added where needed. You won't see any changes to your ads when the script runs if it doesn't need to make any. This is a quieter approach than previous tagging methods.

JavaScript
function updateAdGroups(){
  const adGroups = AdsApp.adGroups().withCondition("CampaignStatus = ENABLED").get();

  // Iterate over all available Ad Groups until we've seen them all.
  while (adGroups.hasNext()) {
    // Grab the next Ad Group on the list and any existing Custom Parameters
    const adGroup = adGroups.next();
    const adGroupParams = adGroup.urls().getCustomParameters();

    // Encode the name so that it's safe for URLs but keep '+' as it is.
    const paramValue = encodeURIComponent(adGroup.getName()).replaceAll('%2B', '+');

    if (adGroupParams.adgroup === paramValue) {
      continue;
    }

    // Add the ad group name to custom parameters.
    Object.assign(
      adGroupParams,
      {
        adgroup: paramValue
      }
    );

    // You can only have 8 custom parameters, so if there are more than that we cannot continue.
    if (Object.keys(adGroupParams).length > 8) {
      console.warn(`Ad Group: ${adGroup.getName()} does not have enough free custom parameters.`);
      continue;
    }

    // Set the updated custom parameters against the ad group.
    adGroup.urls().setCustomParameters(adGroupParams);
  }
}

Save this section of the script as Ad Group.gs.

Step 7: add the main script

Click the blue + icon to open a new script window, then copy and paste the text below. This part of the script runs the other two parts.

JavaScript
function main(){
  updateCampaigns();
  updateAdGroups();
}

Save this section of the script as Code.gs. Your window should now look like this:

Step 8: preview and run the scripts

  1. Click the Preview button at the bottom right of the screen. This shows the changes that will be made without making them. You can also check the Logs tab for any warnings, such as ad groups that do not have enough free custom parameters.
  2. If you are happy with the results, click Save. You can then click Run, and the script makes the changes from the preview.

Running a preview also triggers a bulk upload, but that upload is still a preview. To see the results, go to Tools > All Bulk Actions. You can apply the campaign changes from the preview in Bulk Actions without running the script again, for example if the preview has campaign changes but no ad group changes.

Step 9: schedule the scripts

  1. After you have run the script, go back to the main Scripts page by clicking Scripts in the left-hand navigation menu. You should see a table with the script you created.
  2. Click the Frequency column for your script. You can then choose to run the script automatically on a schedule. Choose a schedule that reflects how often you change your campaigns and ad groups.

Click Save, and the script runs on the schedule you chose. You can return to this page to see when the script last ran and what the outcome was.

Step 10: remove the Infinity tagging sync

If you use Infinity's tagging sync for the account, managed from the Google Ads integration in Infinity, disable it before you go to the next step, so the two methods don't conflict.

  1. Log in to the Infinity Platform and select Settings from the bottom of the left-hand navigation.
  2. Under Integrations, select Google Ads, then click the Account Tagging tab. This shows the list of Google Ads accounts that are being synced with Infinity.
  3. If the account you are adding custom ValueTrack parameters to is in this list, select it, click the three dots on the right-hand side, and select Delete account.

Step 11: remove existing Infinity tracking templates

If you have used Infinity tracking templates at campaign or ad group level before, remove them, so that the tag isn't duplicated. Create a new script in Google Ads, following the same steps as above, and paste in the text below.

JavaScript
function main(){
  const adGroups = AdsApp.adGroups().withCondition("CampaignStatus = ENABLED").get();

  while (adGroups.hasNext()) {
    const adGroup = adGroups.next();
    const adGroupTrackingTemplate = adGroup.urls().getTrackingTemplate();

    if (adGroupTrackingTemplate && adGroupTrackingTemplate.indexOf('infinity{ifcontent:display}') > -1) {
      adGroup
        .urls()
        .setTrackingTemplate(
          adGroupTrackingTemplate.replace(/(?<=&|\?)infinity{ifcontent:display}(=[^&]*)?(&|$)/, '').replace(/{lpurl}\?$/, '{lpurl}')
        );
    }
  }

  const campaigns = AdsApp.campaigns().withCondition("CampaignStatus = ENABLED").get();

  while (campaigns.hasNext()) {
    const campaign = campaigns.next();
    const campaignTrackingTemplate = campaign.urls().getTrackingTemplate();

    if (campaignTrackingTemplate && campaignTrackingTemplate.indexOf('infinity{ifcontent:display}') > -1) {
      campaign
        .urls()
        .setTrackingTemplate(
          campaignTrackingTemplate.replace(/(?<=&|\?)infinity{ifcontent:display}(=[^&]*)?(&|$)/, '').replace(/{lpurl}\?$/, '{lpurl}')
        );
    }
  }
}

This script tries to remove any Infinity templates from ad group and campaign level tracking templates. You only need to run it once.

Step 12: add the Infinity tracking template

Now that your custom ValueTrack parameters are set up, add the Infinity tracking template to your account, so that all your paid search activity can be tracked.

  1. Go to the Google Ads home page, making sure you are on the account you want to update.
  2. In the left-hand menu, go to Admin > Account settings.
  3. Click Tracking in the list. This expands so you can update the Tracking template or the Final URL suffix. The Infinity tracking template can be used in either, so use the one that makes the most sense for your account.
  4. Enter the following into the tracking field you want to use, following its formatting rules, then click Save.
Text
infinity{ifcontent:display}=ict2~net~gaw~cmp~{_campaign}~ag~{_adgroup}~ar~{creative}~kw~{ifsearch:{keyword}}{ifcontent:{placement}}~mt~{matchtype}{ifcontent:c}

Previous Google Ads tagging method

If you have already set up Google Ads tagging with a previous method, the Infinity template is below. The number at the end is the Customer ID, so replace it with your own:

Text
infinity{ifcontent:display}=ict2~net~gaw~cmp~{campaignid}~ag~{adgroupid}~ar~{creative}~kw~{ifsearch:{keyword}}{ifcontent:{placement}}~mt~{matchtype}{ifcontent:c}~acr~123456789

Set up Google Ads tagging at MCC level

Google Ads tagging with custom ValueTrack parameters can also be applied at MCC level, but it needs a small change. Follow the steps above and set up the scripts on the MCC account. Instead of the main script in Step 7, use the script below:

JavaScript
function main() {
  // Run on each account in parallel
  AdsManagerApp.accounts().executeInParallel('updateCampaigns');
  AdsManagerApp.accounts().executeInParallel('updateAdGroups');
}

This runs the ValueTrack sync on each account under the MCC.

Watch the video: Google Ads tagging using custom ValueTrack parameters: video walkthrough

Option 2: set up Google Ads tagging in the Infinity Platform

Infinity adds the scripts and tracking template to your Google Ads account for you. If you want to tag at MCC level, don't want to connect your account to Infinity, or prefer to manage the scripts yourself, follow Option 1 above instead.

Check your role

You need either the Administrator or Integration Manager role to access the tagging settings in the Infinity Platform.

Open Google Ads tagging

Log in to the Infinity Platform and select Settings from the bottom left-hand navigation. Then choose Google Ads from the Integrations section. The page has two tabs. Conversion Tracking is where your integrations with Google Ads are set up. Account Tagging is where tagging is set up. Select Account Tagging to see your Google Ads accounts that are set up for tagging. Each account shows the date it was added and the date its data was last synced, with a green or red label showing whether it is enabled.

How it works

When you add a Google Ads account to the Account Tagging list, Infinity adds a script to your Google Ads account, so the custom ValueTrack parameters we need are available on the final URLs. Infinity then adds a tracking template at account level, as a final URL suffix, to capture the details we need.

Add an account

Select Account Tagging, log in to your Google Ads account, and use the dropdown to select the Google Ads account you want to tag. Google doesn't support tracking templates at MCC level. This means you can only add client-level accounts for tagging, even if you use an MCC account to connect Infinity and send event data to Google Ads.

Disable or delete an account

You can disable or delete an account at any time. Select the account in the Account Tagging list, click the three dots on the right-hand side, then select Disable or Delete.

The Infinity template

If you ever need it, the Infinity template that Infinity adds as an account-level final URL suffix is:

Text
infinity{ifcontent:display}=ict2~net~gaw~cmp~{campaignid}~ag~{adgroupid}~ar~{creative}~kw~{ifsearch:{keyword}}{ifcontent:{placement}}~mt~{matchtype}{ifcontent:c}

Troubleshooting

There are three known errors that can affect a tagging account: Invalid Credentials, Login Customer Invalid and Account Deleted. The error message is shown alongside the error label. Use the more menu (three dots) to resolve them.

Invalid credentials

This means the credentials used for the account are invalid. Click the three dots to sign in to Google and use your credentials instead.

Account can't make changes

This means we don't have a valid login customer ID for the account. Click the three dots and choose Fix account. You can then log in to Google, select the account from the dropdown, and re-enable the account.

Ads account is deleted

This means the Google Ads account has been deleted. The only fix is to delete the account from the list of tagged accounts. Click the three dots and select Delete account.

Additional information

Normally, when a Google Ads tagging account is deleted, Infinity removes the Infinity tracking template from that Google Ads account. In some cases, for example if the credentials used to create the account are no longer valid, Infinity can't remove the template. If you see a warning after deleting an account, remove the Infinity tracking template from your Google Ads account manually.

Changes to Google Ads tagging in July 2025

Infinity first added support for tagging Google Ads accounts in the Infinity Platform in 2022. In July 2025, the Account Tagging approach was updated to use the same scripts as Option 1. Existing customers don't need to do anything, as these changes are made automatically. You may notice campaigns appearing with URL parameters when you edit them in Google Ads, and URLs in the Infinity Platform may be listed by their page name instead of their ID.

Need more help?

For more on the Google Ads integration itself, read our Google Ads integration guide. If you need help with Google Ads tagging, get in touch with your Customer Success Manager or email support@infinity.co.