简体   繁体   English

从Google Analytics API的当前视图中检索adWordsCampaignID

[英]Retrieve adWordsCampaignID from current view in Google Analytics API

Using only the Analytics API, I've discovered you can pull Adwords data by specifying the adwordsCampaignID However, I cannot figure out how to retrieve the adwordsCampaignID of the current view, or alternately, to get it by filtering on some property of the current view. 我发现仅使用Analytics API,就可以通过指定adwordsCampaignID来提取Adwords数据。但是,我无法弄清楚如何检索当前视图的adwordsCampaignID或通过筛选当前视图的某些属性来获取它。

I cycle through several dozen domains and need to pull the adwordsCampaignID of each view & insert it into the following function. 我循环浏览了几十个域,需要提取每个视图的adwordsCampaignID并将其插入以下函数。 a 一种

function getAdWords(&$analytics, $profileId) {
   return $analytics->data_ga->get(
       'ga:' . $profileId,
       '2014-07-01',
       '2014-09-09',
      'ga:adClicks,ga:CTR,ga:impressions', 
      array('dimensions' => 'ga:adwordsCampaignID,ga:adwordsAdGroupID,ga:adGroup,ga:keyword','sort' =>
            '-ga:impressions','filters' => 'ga:adwordsCampaignID=='.'8486***','max-results' => '50')

       );

} }

Something along the lines of $results = getAdwordsCampaignID($analytics);

Turns you can pull AdWords data using only the Google Analytics API (as long as your GA account is joined to the AdWords account). 轮流您可以仅使用Google Analytics(分析)API提取AdWords数据(只要您的GA帐户已加入AdWords帐户)。

Can be done like this: 可以这样做:

function getAdWords(&$analytics, $profileId) {
   return $analytics->data_ga->get(
       'ga:' . $profileId,
       '2014-07-01',
       '2014-09-09',
      'ga:adClicks,ga:CTR,ga:impressions', 
      array('dimensions' => 'ga:adwordsCampaignID,ga:adwordsAdGroupID,ga:adGroup,ga:keyword','sort' =>
            '-ga:impressions','filters' => 'ga:adwordsCampaignID=='.'84*690*','max-results' => '50')

       );

}

However, there are limitations. 但是,有局限性。 You must have the adWordsCampaignID. 您必须具有adWordsCampaignID。 As far as I can tell, there is no way to retrieve the adWordsCampaignID of a view using only the GA API. 据我所知,无法仅使用GA API来检索视图的adWordsCampaignID。 You must join the data between the AdWords + GA APIs using the CustomerID variable. 您必须使用CustomerID变量在AdWords + GA API之间加入数据。

The Google API Query Explorer is a great help if you are working to implement this. 如果您正在努力实现这一点,那么Google API查询浏览器将为您提供很大的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM