Dear Support Team,

I am experiencing an issue with a Google Ads script where the keyword 
placeholder {keyword} is not being passed correctly in the final URL. My 
goal is to pass the keyword, which triggered the ad, directly in the URL. 
Unfortunately, this does not seem to be working as expected.

Here is the relevant script snippet:

function main() {
    var adGroupIterator = AdsApp.adGroups()
      .withCondition("CampaignStatus = ENABLED")
      .get();
  
    while (adGroupIterator.hasNext()) {
      var adGroup = adGroupIterator.next();
      var gn = adGroup.getName();
      var cn = adGroup.getCampaign().getName();
      var src = 'google';
      var mdm = 'sea';
  
      // Create the final URL suffix with a placeholder for the keyword
      var finalSuffix = 'utm_source=' + src +
                       '&utm_medium=' + mdm +
                       '&utm_campaign=' + encodeURIComponent(cn) +
                       '&utm_content=' + encodeURIComponent(gn) +
                       '&utm_term={keyword}';
      
      // Encode the final suffix to ensure proper URL format
      finalSuffix = encodeURI(finalSuffix);
  
      // Set the final URL suffix for the ad group
      adGroup.urls().setFinalUrlSuffix(finalSuffix);
    }
  }

Issue:
   
   - The {keyword} placeholder does not get replaced with the actual 
   keyword that triggered the ad.

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/2393ae83-1552-42be-b051-35617e7f24d5n%40googlegroups.com.
  • Ke... Markus
    • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum

Reply via email to