AdWords
3.1K members online now
3.1K members online now
Use AdWords conversion tracking and reporting to measure your results. Have a question about Google Analytics? Post it here, on the Google Analytics Community!
Guide Me
star_border
Reply

ADWORDS scripts

Follower ✭ ☆ ☆
# 1
Follower ✭ ☆ ☆

hello,

 

i am starting to learn adwords scripts and i came accross a problame when i used one of the examples adwords provide in the scripts page inside adwords.

 

i dont understand why the log output shows nothing when i ask some stats for a specific campaign.

 

this is the code i tried:

 

function main() {
 function getCampaignStats() {
var campaignIterator = AdWordsApp.campaigns()
.withCondition('Name = "קופת גמל להשקעה - BMM"')
.forDateRange("YESTERDAY")
.get();
if (campaignIterator.hasNext()) {
var campaign = campaignIterator.next();

var stats = campaign.getStatsFor('YESTERDAY');
Logger.log(campaign.getName() + ', ' + stats.getClicks() + 'clicks, ' +
stats.getImpressions() + ' impressions');
}
}
}

1 Expert replyverified_user

Re: ADWORDS scripts

Top Contributor
# 2
Top Contributor

Hi @Tomer N can you try this version of the script?

 

function main() {
  getCampaignStats();
}

function getCampaignStats() {
  var campaignIterator = AdWordsApp.campaigns()
  .withCondition("Name = 'קופת גמל להשקעה - BMM'")
  .get();
  while(campaignIterator.hasNext()) {
    var campaign = campaignIterator.next();
    var stats = campaign.getStatsFor('YESTERDAY');
    Logger.log(campaign.getName() + ", " + stats.getClicks() + " clicks, " +
    stats.getImpressions() + " impressions");
  }
}

 

AdWords Top Contributor Google+ Profile | Partner Profile | AdWords Audits

ADWORDS scripts

Follower ✭ ☆ ☆
# 3
Follower ✭ ☆ ☆

Thanks @Jon_Gritton it worked! but why the adowords suggested example didnt work as well?