问题描述
我正在处理一个项目,我需要使用 Google Analytics 服务器端.我不需要检索信息,但我需要发送信息.我最终可以发送 js 脚本客户端,但在这种情况下它不是一个选项.
I am working on a project and I need to use Google Analytics server side. I do not need to retrieve information, but I need to send information. I could eventually send js script client side, but in this scenario it is not an option.
以下大部分链接真的很旧.2012~
我已经阅读了多篇 StackOverflow 帖子,但他们只提到了检索信息的方法.
I have read multiple StackOverflow posts, but they only mention ways to retrieve information.
Google Analytics 的 PHP API(SO)
有一篇关于发送信息的帖子,但该库已弃用 GitHub.
There is this one post talking about sending information but the GitHub has been deprecated for that library.
Google Analytics PHP API 重定向 URI (SO)
Google api php 客户端(GOOGLE)
如何使用 PHP 将信息发送到我的 Google Analytics(分析)帐户?谢谢
How do I send information to my Google Analytics account in PHP? Thanks
推荐答案
您通过 测量协议.不需要特殊的库或开发工具包,您只需将参数附加到 GA 端点并通过 Curl/fopen/sockets/whatever 将它们发送到 Google Analytics.
You send data via the Measurement Protocol. No special library or dev kit is required, you simply append parameters to the GA endpoint and send them via Curl/fopen/sockets/whatever to Google Analytics.
每个调用至少包含您要向其发送数据的帐户的 ID、一个允许将交互分组到会话中的客户端 ID(因此它应该是每个访问者的唯一标识,但它不能识别用户的个人身份)、一个交互类型(浏览量、事件、时间等,某些交互类型需要额外参数)和您使用的协议版本(目前只有一个版本).
Each calls includes at least the ID of the account you want to send data to, a client id that allows to group interactions into sessions (so it should be unique per visitor, but it must not identify a user personally), an interaction type (pageview, event, timing etc., some interactions types require additional parameters) and the version of the protocol you are using (at the moment there is only one version).
因此,记录浏览量的最基本示例如下所示:
So the most basic example to record a pageview would look like this:
www.google-analytics.com/collect/v=1&tid=UA-XXXXY&cid=555&t=pageview&dp=%2Fmypage
这篇关于Google Analytics PHP(发送信息)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)