Google Analytics PHP (Sending information)(Google Analytics PHP(发送信息))
问题描述
我正在处理一个项目,我需要使用 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(发送信息)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Google Analytics PHP(发送信息)
基础教程推荐
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何替换eregi() 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
