Skip to main content
 首页 » 编程设计

web之如何从 Google Analytics Reporting API 获取关键字类型(有机或付费)

2025年05月04日65qlqwjy

我正在使用谷歌分析核心报告 API。我有一点困惑,我想讨论一下。

首先,我想获取用户在我的网站上搜索过的关键字。我用过ga:keyword .我还看到了另一个维度,即 ga:searchKeyword .其中哪一项会给我渴望的结果?

其次,我想获得关键字类型是有机的还是付费的?如果我将使用 ga:medium那么它会给我搜索关键字的类型吗?

BTY 使用以下函数获取结果

private function getResults(&$analytics, $profileId,$data) { 
 
    $optParams = array( 
 
        'dimensions' => 'ga:visitCount,ga:browser,ga:fullReferrer,ga:keyword,ga:country,ga:campaign,ga:medium' 
        ); 
 
    return $analytics->data_ga->get( 
            'ga:' . $profileId, $data['start_date'], $data['end_date'], 'ga:visits',$optParams); 
} 

请指导我。

最好的祝福,

请您参考如下方法:

ga:searchKeyword仅适用于来自您的内部网站搜索的关键字。 ga:keywordga:medium会给出想要的结果。

根据documentation , ga:keyword轨道:

When using manual campaign tracking, the value of the utm_term campaign tracking parameter. When using AdWords autotagging or if a visitor used organic search to reach your property, the keywords used by visitors to reach your property. Otherwise the value is (not set).


ga:medium可用于区分自然搜索和付费点击。它跟踪:

The type of referrals to your property. When using manual campaign tracking, the value of the utm_medium campaign tracking parameter. When using AdWords autotagging, the value is ppc. If the user comes from a search engine detected by Google Analytics, the value is organic. If the referrer is not a search engine, the value is referral. If the visitor came directly to the property, and document.referrer is empty, the value is (none).