Getting Keyword Impr. (Top)% and Impr. (Absolute Top)%

234 views
Skip to first unread message

Todd Gardner

unread,
Mar 20, 2019, 9:37:24 PM3/20/19
to Google Ads Scripts Forum
How do I access Impression (Top)% and Impression (Absolute Top)% from Google Ads Scripts? They do not appear to be documented in the Keyword Reference.

I currently use Google Ads script to adjust my keyword bidding based on AveragePosition. However, with AveragePosition being retired this year in favor of Impression (Top) and Impression (Absolute Top) metrics, I need to switch over. These new fields are visible in the UI and in the Rule builder, but I cannot find them in the scripting reference.

Todd Gardner

unread,
Mar 20, 2019, 9:42:12 PM3/20/19
to Google Ads Scripts Forum
I figured out how to do this, but it's a little HACKY™.

The Top Impressions and Abs Top Impressions are not revealed on the Keyword or Statistics API, but they are in the Reporting API in the KEYWORDS_PERFORMANCE_REPORT. I used that report to build a lookup object of all the keywords by Id with the data I wanted. Something like this:


function getTopImprPct(keyword) {
  return getKeywordPerformance(keyword.getId(), 'TopImpressionPercentage');
}

function getAbsTopImprPct(keyword) {
  return getKeywordPerformance(keyword.getId(), 'AbsoluteTopImpressionPercentage');
}

function getKeywordPerformance(keywordId, metric) {
  if (!keywordPerformanceLookup) { buildKeywordPerformanceLookup(); }
  if (keywordPerformanceLookup[keywordId] && keywordPerformanceLookup[keywordId][metric]) {
    return keywordPerformanceLookup[keywordId][metric];
  }
  else {
    Logger.log('Lookup miss for metric %s on keyword %s', metric, keywordId);
    return 0.0;
  }
}

var keywordPerformanceLookup = null;
function buildKeywordPerformanceLookup() {
  keywordPerformanceLookup = {};
  var keywordPerformanceReportRows = AdsApp.report(
    'SELECT Id, Criteria, AbsoluteTopImpressionPercentage, TopImpressionPercentage ' +
    'FROM KEYWORDS_PERFORMANCE_REPORT ' +
    'WHERE CampaignStatus = ENABLED ' +
    'AND AdGroupStatus = ENABLED ' +
    'AND Status = ENABLED ' +
    'AND IsNegative = FALSE ' +
    'AND Impressions > 0 ' +
    'DURING TODAY').rows();
  while(keywordPerformanceReportRows.hasNext()) {
    var row = keywordPerformanceReportRows.next();
    keywordPerformanceLookup[row['Id']] = {
      TopImpressionPercentage: row['TopImpressionPercentage'],
      AbsoluteTopImpressionPercentage: row['AbsoluteTopImpressionPercentage']
    };
  }
}

Now, I can call getTopImprPct with the keyword I want and get the value back, so long as I make sure I am considering the same time range. Everything in my script is looking at TODAY, so everything matches up, but YMMV.

googleadsscrip...@google.com

unread,
Mar 20, 2019, 11:48:50 PM3/20/19
to adwords...@googlegroups.com, Google Ads Scripts Forum
Hi Todd,

It appears that you already found a way to create a workaround about your concern.

Please let me know if you have further questions/concerns and I would be happy to provide support.

Regards,
Ejay
Google Ads Scripts Team
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_scripts
    https://developers.google.com/google-ads/scripts/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-scripts+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/d579672c-a6b1-497f-9bf6-a7f6510b0a03%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages