Adwords Tracking Template – {CampaignName} & {AdGroupName} Parameters

Google Ads Value Track Parameters - {CampaignName} & {AdGroupName}

[UPDATED: 26-04-2019 – Works With New Google Ads]

Many of my colleagues had struggled while tagging the urls with the value track parameters, as they had to manually tag ‘CampaignName’ or ‘AdgroupName’ at campaign/adgroup level.

It is also time consuming job, if you have like 1000s of campaigns and 10,000s of adgroups. This script will tag those 10,000 adgroups in a few seconds.

I guess most of the people who use tracking template do track ‘CampaignName’ or ‘AdGroupName’.

How To Use ?

Step 1:

  1.  Enter the Tracking Template in the similar format as you would enter in adwords tracking template. Include atleast one of {CampaignName} or {AdGroupName} in the tracking template.
  2. Some of the template examples:
    • {lpurl}?utm_source=google&utm_medium=cpc&utm_campaign={CampaignName}~{AdGroupName}
    • {lpurl}?utm_source=google&utm_medium=cpc&utm_adgroup={AdGroupName}&utm_campaign={CampaignName}&d={device}
    • {lpurl}?utm_source=google&utm_medium=cpc&utm_campaign={CampaignName}||{AdGroupName}
    • {lpurl}?utm_source=google&utm_medium=cpc&utm_campaign={CampaignName}

Step 2:

  • There are two filters ‘Adgroup name contains’ and ‘Campaign name contains’.
  • If both are entered, it will ‘AND’ these conditions.
  • The tracking template will only be added to the campaign/adgroup, as per the filters.
  • If you want all campaigns or all adgroups to be included, then just leave it blank.
  • For Example:
    • For all campaigns: _CAMPAIGN_CONTAINS=””;
    • For all adgroups: _ADGROUP_CONTAINS=””

Step 3:

  • Preview the script.
  • If the url template has been entered properly, you can see the expected output in ‘Changes’ & also in “Logs”.
  • If error is encountered, check logs.

 

Use Case:

I want to add tracking template to all my campaign names containing ‘products’ as a word.

Step 1:

  • I have pasted my tracking template with {CampaignName} and {AdGroupName} as parameters.

So, I have pasted my tracking template as shown, Now i can preview the script:

Step 2:

  • I can now preview the script & check the parameters applied.
  • I can see that the adgroup name is appended correctly and also its respective campaign name.
  • Also, only the campaigns with “Product” in their campaign name are tagged.
  • I can now run the script.

I hope this solves much of the manual work needed for tagging the urls.

Update [26-04-2019]

  • Support for “All URL format” added.
  • Support for new Google Ads.
  • Fixed Bugs. 

Ritwik is a Web Analyst & Product Marketer. He loves to write technical & easy to understand blogs for Marketers & Entrepreneurs. Focused on Google Analytics, Facebook Analytics, Tag Management, Marketing & Automation Scripts & more. Google Certified Professional. A Firm Believer in Teaching -> Learning -> Growing. :)

Comments (18)

  1. Hey.. Thanks a lot..!!! That filter worked great

  2. Hi there,

    Just tried to apply the script but unfortunately I get the following message error “Invalid tracking template”. My new url seems all ok but there are spaces in it. Can this be the origin of the problem?

    Thanks,

    Damien

    1. Hi Damien,

      “Invalid Tracking template” mostly refers to spaces in tracking template.
      Make sure the template “{lpurl}?utm_source=xyz……” is without space. Also, kindly check the updated script & do let me know.(I have fixed some bugs)

      Thanks for message.!!!

      1. Hi Ritwik,
        Your updated script works perfectly! Thanks a lot for your swift update on it.
        Cheers,

        Damien

  3. Is this script tweak-able to accept a parameter with a string of concatenated values? I’ve tried adding in the following;

    ?track=google~{CampaignName}~{AdGroupName}~{ifsearch:{keyword}}{ifcontent:{placement}}~{matchtype}{ifcontent:c}

    with no joy. Any suggestions?

    1. Hi Ashley,

      Unfortunately, I never thought of the above scenario while creating script :/ . But if you have a developer, he/she can help with editing.

      Thanks,
      Ritwik

    2. Did you ever find a work around for this @disqus_3Q0KDX3IMV:disqus? I see now quite a few people would like to concatenate the values (myself included!). Cheers

  4. Hi Ritwik,

    I should have seen your post earlier! Thanks so much! It worked!

    1. Hey Connie, That’s Great.!!

      1. Hi Ritwik,

        I am trying to make utm_campaign=CampaignName_AdGroupName, for example: utm_campaign=ShoeCampaign_TrainerAdGroup.

        How can I do that? Thanks!

        Connie

        1. Did you ever find a work around for this @disqus_53UtRCPDrA:disqus? I see now quite a few people would like to concatenate the values (myself included!). Cheers

  5. I think the script is not working on Shopping Ads (e.g. PLA)?
    What are the supported campaign types? And can you modified the script to support more campaign types?
    Thanks!

  6. Hi! I am not that experienced with auto tagging in adwords, but I am trying to set this up for a colleague. Would adding this: &utm_term={Keyword} at the end add the keyword per ad?

    Or would I be able to add this at the ad level?

  7. Hi @ritwikb:disqus,

    This is exactly what I’m looking for but get the following error:

    —————————————-

    TypeError: Cannot call method “split” of undefined. (file Code.gs, line 68)

    —————————————-

    Below are my Tracking Template details I added to the script to preview test:

    —————————————-

    var TrackingTemplate=”{lpurl}&mkwid={ifsearch:s}{ifcontent:c}{_mkwid}&crid={creative}&mp_kw={keyword}&mp_mt={matchtype}&utm_source=google&utm_medium=cpc&utm_campaign={_gmscampaign}&utm_content={_mktchannel}{CampaignName}_{AdGroupName}&utm_term={keyword}”; //Example

    var _CAMPAIGN_CONTAINS=””; //Filter by Campaign name
    var _ADGROUP_CONTAINS=””; //Filter by Adgroup name
    var STATUS=”ENABLED”; //ENABLED, PAUSED

    —————————————-

    Any ideas to why this would be? (apologies not a coder).

    Cheers

    1. Having the same issue with this one:

      {lpurl}?pk_campaign={CampaignName}|{AdGroupName}&pk_source=google&pk_medium=cpc&pk_keyword={keyword}&pk_content={creative}&pk_cid={campaignid}

  8. Hi Ritwik,

    Thanks for the scripts! I tried to use it, it works fine on the preview, while when I run it, the result shows invalid tracking template, you know what might be the reason for that? thanks!

  9. Does this script need to run more than one time? Should I set the frequency to run more than once?

  10. Hello Ritwik,
    This script is still very useful!
    Do you know if we can have it also at the sitelink level?
    My goal would be to provide the following parameters: utm_campaign={CampaignName}&utm_content=sitelink-name:
    Unfortunately the track parameter only allows {campaignid} and not {campaignname}. Do you know of any workaround?
    Thanks a lot!

Leave a Reply

Your email address will not be published. Required fields are marked *