您可以将自己的查询字符串参数添加到脚本顶部的映射中。 例如,如果帐户中的所有关键字都需要在其目标网址中包含参数“ channel = sem”,则可以将其添加到文件顶部的URL_PARAMS_TO_ADD映射中,并将其添加到所有网址中。
另外,我更新了脚本,允许您将帐户中想要的任何值添加到url中。如果愿意,请参见将广告系列和广告组名称添加到网址的示例。
谢谢,
拉斯
/****************************************** * Auto Add 价值追踪 (and other) Params If Not There * Created By: 拉斯 Savage * Version 1.1 * ChangeLog v1.1 * - Added the ability to 广告 d function 呼叫s into the parameters to 广告 d * FreeAdWordsScripts.com ******************************************/ function main() { var URL_PARAMS_TO_ADD = { "kw" : "{keyword}", "crid" : "{creative}", "mt" : "{matchtype}", "ntwk" : "{network}", "ap" : "{adposition}", "dv" : "{device}", "dvm" : "{devicemodel}", //"camp" : getCampaignName, <----- This function is defined below //"ag" : getAdGroupName <----- and so is this one }; var kw_iter = AdWordsApp.keywords() .withCondition("DestinationUrl != ''") .get(); while(kw_iter.hasNext()) { var kw = kw_iter.next(); var destUrl = kw.getDestinationUrl(); if(!destUrl || destUrl === '') { continue; } var toAppend = []; for(var key in URL_PARAMS_TO_ADD) { if(destUrl.indexOf(key) >= 0) { continue; } var value = URL_PARAMS_TO_ADD[key]; //check to see if we should 呼叫 a function if(typeof(value) === 'function') { value = encodeURI(value(kw)); } toAppend.push(key+"="+value); } if(destUrl.indexOf('?') >= 0) { kw.setDestinationUrl(destUrl + "&"+toAppend.join('&')); } else { kw.setDestinationUrl(destUrl + "?"+toAppend.join('&')); } Logger.log(kw.getDestinationUrl()); } } // As long as the function 呼叫 is passed a kw object, you can insert // whatever value you want into the url function getCampaignName(kw) { return kw.getCampaign().getName(); } function getAdGroupName(kw) { return kw.getAdGroup().getName(); }