Mobile Apps

Add a mobile app extension to a campaign

function addMobileApp() {
  var campaignIterator = AdWordsApp.campaigns()
      .withCondition('Name = "INSERT_CAMPAIGN_NAME_HERE"')
      .get();
  if (campaignIterator.hasNext()) {
    var campaign = campaignIterator.next();
    // See https://support.google.com/adwords/answer/2402582 for details on how
    // to obtain applications specific store id
    var newMobileApp = AdWordsApp.extensions().newMobileAppBuilder()
        .withAppId('store specific app id')                  // required
        .withStore('Android')                                // required
        .withLinkText('Download Android App Here')           // required
        .withFinalUrl('http://wwww.example.com/androidApp')  // required
        .withStartDate({day: 12, month: 9, year: 2013})      // optional
        .build()
        .getResult();

    // Add mobile app to campaign. Adding mobile apps to ad groups is similar.
    campaign.addMobileApp(newMobileApp);
  }
}

Get mobile app extensions for a campaign

function getMobileAppsForCampaign() {
  var campaignIterator = AdWordsApp.campaigns()
      .withCondition('Name = "INSERT_CAMPAIGN_NAME_HERE"')
      .get();
  if (campaignIterator.hasNext()) {
    var campaign = campaignIterator.next();
    var mobileAppsIterator = campaign.extensions().mobileApps().get();

    while (mobileAppsIterator.hasNext()) {
      var mobileApp = mobileAppsIterator.next();
      Logger.log('Mobile app id: ' + mobileApp.getAppId() +
          ', link text: ' + mobileApp.getLinkText() +
          ', final URL: ' + mobileApp.urls().getFinalUrl());
    }

    Logger.log(mobileAppsIterator.totalNumEntities() +
        ' mobile apps in the account');
  }
}

Get stats for mobile app extensions in a campaign

function getMobileAppStats() {
  var campaignIterator = AdWordsApp.campaigns()
      .withCondition('Name = "INSERT_CAMPAIGN_NAME_HERE"')
      .get();
  if (campaignIterator.hasNext()) {
    var campaign = campaignIterator.next();
    // Retrieve the campaign's mobile apps. Retrieving an ad group's mobile
    // apps is similar.
    var appsIterator = campaign.extensions().mobileApps().get();

    while (appsIterator.hasNext()) {
      var apps = appsIterator.next();
      // You can also request reports for pre-defined date ranges. See
      // https://developers.google.com/adwords/api/docs/guides/awql,
      // DateRangeLiteral section for possible values.

      var stats = apps.getStatsFor('LAST_MONTH');
      Logger.log(sitelink.getLinkText() + ', ' + stats.getClicks() + ', ' +
          stats.getImpressions());
    }
  }
}

发送以下问题的反馈:

此网页
AdWords Scripts
AdWords Scripts
需要帮助?请访问我们的支持页面