Can you setTrackingTemplate at Account Level? - MCC Script

288 views
Skip to first unread message

lea.h...@commissionsinc.com

unread,
Sep 22, 2021, 3:18:41 PM9/22/21
to Google Ads Scripts Forum
Hello,
We want to apply tracking templates at the account level for all accounts in our MCC (if possible) using Scripts, and at the campaign level if it's not possible to set them at the account level. 

Below is the script I'm using to set them at the campaign level. 

Earlier I tried including 
account.urls().setTrackingTemplate(trackingTemplate);

and received an error about urls() not being available in object account

Is it possible to setTrackingTemplate for the accounts? Thanks in advance for your help! 

var RECIPIENT_EMAIL = 'your...@youremailprovider.com';
function main() {
  var timeZone = AdWordsApp.currentAccount().getTimeZone();
  var spreadsheet = SpreadsheetApp.create("Tracking Template added to Campaigns - " + Utilities.formatDate(new Date(), timeZone, 'yyyyMMdd'));
  var sheet = spreadsheet.getActiveSheet();
  sheet.appendRow(['Account Name', 'Account ID', 'Campaign Name', 'Campaign ID']);

  var trackingTemplate = "{lpurl}?campaign={campaignid}&content={creative}&keyword={keyword}&device={device}"

  var accountIterator = MccApp.accounts()
 .orderBy("Clicks ASC")
 .withCondition("Clicks > 0")
         .forDateRange("THIS_MONTH") 
   .withCondition("Name DOES_NOT_CONTAIN_IGNORE_CASE 'test'").get();
 
  while (accountIterator.hasNext()) {
    var account = accountIterator.next();
    MccApp.select(account);
    
 var cmpgn = AdsApp.campaigns()
    .withCondition("AdvertisingChannelType = SEARCH")
    .get();
 
  while (cmpgn.hasNext()){
    var a = cmpgn.next();
    a.urls().setTrackingTemplate(trackingTemplate);
     
    sheet.appendRow([account.getName(), account.getCustomerId(), a.getName(), a.getId()]);
    }
   
}
  
  Logger.log('Tracking Template added to: ' + spreadsheet.getUrl());
   MailApp.sendEmail(RECIPIENT_EMAIL, 'Campaigns with tracking template applied.', spreadsheet.getUrl());

}

Google Ads Scripts Forum Advisor

unread,
Sep 22, 2021, 11:06:23 PM9/22/21
to adwords...@googlegroups.com
Hi Lea,

Thanks for reaching out. Harry here, from the Google Ads Scripts Team.

Unfortunately, managing tracking templates at the Account level is currently not supported in Google Ads Scripts. Please see AdsApp.​Account and AdsManagerApp.​ManagedAccount for your reference. On the other hand, I can reach out to the rest of the team and communicate a feature request on your behalf but kindly take note that all requests are subject for approval and are not guaranteed to be supported anytime soon via scripts. Kindly let me know if you would like to proceed with such request and provide a sample use case / justification to the feature.

Looking forward to your reply.

Thanks,
Google Logo
Harry Cliford Rivera
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2OTElq:ref

lea.h...@commissionsinc.com

unread,
Sep 23, 2021, 9:18:15 AM9/23/21
to Google Ads Scripts Forum
Thank you, Harry,
A feature request for setting account level tracking templates through scripts would be great, thank you. We'll go with setting at the campaign level.

Best,
Lea

Google Ads Scripts Forum Advisor

unread,
Sep 23, 2021, 11:17:44 PM9/23/21
to adwords...@googlegroups.com
Hi Lea,

Thanks for confirming. Would you mind sending a sample use case / justification to the feature so I can add more details upon filing the request?

lea.h...@commissionsinc.com

unread,
Sep 24, 2021, 6:43:56 PM9/24/21
to Google Ads Scripts Forum
Hi Harry,

Sample use case / justification is that we have a large MCC and are adding tracking templates to analyze which keywords are bringing in the most ROI, based on a setting in our CRM/bringing keyword data into the CRM to be able to do this analysis. In the future, we'll start setting this tracking template for every newly created campaign through the API at the time of campaign creation, but for now, we need to add the tracking template to most of the existing accounts in our MCC. Adding at the account level rather than campaign level through scripts would allow us to have any campaigns that are created within a child account in the future automatically contain/inherit the tracking template, rather than having to run the script every so often through the whole MCC to catch any newly created campaigns and apply the template to those new campaigns that don't yet have the template. 

Thanks,
Lea

Google Ads Scripts Forum Advisor

unread,
Sep 27, 2021, 12:38:01 AM9/27/21
to adwords...@googlegroups.com
Hi Lea,

Thanks for your cooperation. I have now raised this request to the rest of the team for consideration. Just to reiterate, please be informed that there is no guarantee that this will be supported in the Google Ads Scripts anytime soon. Kindly follow our blog for updates and new releases in the meantime.
Reply all
Reply to author
Forward
0 new messages