php - Google Analytics 跟踪自定义属性

标签 php google-analytics-api

如何跟踪我网站上每个页面的自定义属性?例如,除了跟踪给定页面的页面浏览量、跳出率等外,我还希望能够跟踪自定义属性(具体来说,是某人点击特定页面上特定链接的次数)。

下面是我希望能够看到的模型(在 Google Analytics 仪表板上或通过 GAPI):

enter image description here

最佳答案

您可以使用事件跟踪来做到这一点。有关详细信息,请参阅谷歌指南: https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide

例子:

<head>
...
<script>
var _gaq=[['_setAccount','UA-XXXX-X'],['_setDomainName', 'example.com'],['_trackPageview']];
...
</head>
<body>
...
<a href="#" onClick="_gaq.push(['_trackEvent', 'Custom Clicks Category', 'Custom Link Clicks Action', 'Custom Label', 1]);">Click me</a>
...
<script>
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>

我没有使用的最后一个参数是 non-interaction 参数,它的用法取决于您的具体情况以及您希望如何影响跳出率。阅读 https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide#non-interaction

关于php - Google Analytics 跟踪自定义属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11614523/

相关文章:

javascript - javascript 中带有两个单词的 attr id

长文本数据中的 PHP/MYSQL 变量

javascript - JS Analytics 电子商务回调

php - 谷歌分析 API : Why is the API data different than what's being seen on the Analytics Dashboard?

php - SplSubject/SplObserver有何用处?

java - 使用 nonce 进行无状态 cookie 身份验证的最佳实践

php - 从 Paypal 捐赠按钮取回捐赠值(value)?

google-analytics - Analytics php api 获取 json 响应

php - 如何从 Google Analytics API 读取事件?

android - 无法将 Google Analytics 集成到我的 Android 应用程序中