如何在PHP中的谷歌分析中显示搜索概述?
显示了Google分析页面
访问
76
我正在使用此功能ga:organicSearches链接在这里developers.google.com/analytics/devguides/reporting/core
我想在我的新分析网站中显示这些数据,但此功能显示我74次访问
我可以知道我错在哪里.
这是我的代码到目前为止: –
$ga1 = new gapi($ga_email,$ga_password);
/* We are using the 'source' dimension and the 'visits' metrics */
$dimensions = array('source');
$metrics = array('visits','organicSearches');
/* We will sort the result be desending order of visits,
and hence the '-' sign before the 'visits' string */
$ga1->requestReportData($ga_profile_id,
$dimensions,
$metrics,
'-visits', // Sort by 'visits' in descending order
$filter, // Filter the data
'2012-10-05', // Start Date
'2012-11-04', // End Date
1, // Start Index
500 // Max results
);
$gaResults = $ga1->getResults();
$i=1;
foreach($gaResults as $result)
{
printf("%-4d %-40s %5d\n",
$i++,
$result->getSource(),
$result->getVisits());
}
echo "\n-----------------------------------------\n";
echo "Total Results : {$ga1->getTotalResults()}";
echo "getOrganicSearches:".$ga1->getOrganicSearches().'<br />';
有没有其他功能来显示这些数据???
谢谢
解决方法:
这是我用来获取自然搜索结果的参数(来自搜索引擎的非付费访问)
$params = array(
'dimensions' => 'ga:source,ga:keyword',
'sort' => '-ga:visits,ga:source',
'filters' = 'ga:medium==organic'
);
请注意’过滤器’行.它的值设置为’ga:medium == organic’.
这将返回有机流量的访问次数,您可以再次拨打付费电话以复制Google Analytics网络应用中的“搜索概述”页面.
标签:php,google-analytics 来源: https://codeday.me/bug/20190709/1412838.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。