php - 在 PHP/Zend 框架中获取 Google Analytics 的 cid

标签 php zend-framework google-analytics measurement-protocol

我想跟踪 API 的使用情况。所以我使用 Zend_Http_Client 将 POST 参数发送到 Google Analytic 的收集器。 Google developers-page告诉我,我必须发送一个 cid(匿名客户端 ID)。但是当它是 _ga-cookie 的一部分时,我如何通过 PHP 发送它?

我应该创建自己的cid吗?还是我太笨了,看不懂手册?
谢谢!

最佳答案

所有参数直接通过Measurement protocol发送必须由您创建。

Client ID / Cid
This anonymously identifies a particular user, device, or browser instance. For the web, this is generally stored as a first-party cookie with a two-year expiration. For mobile apps, this is randomly generated for each particular instance of an application install. The value of this field should be a random UUID (version 4) as described in http://www.ietf.org/rfc/rfc4122.txt

我通常使用GUID为了这。似乎有一个 PHP 函数可以执行此操作: com_create_guid或者也许uniqid

答案:

  1. 是的,您应该创建自己的 cid。
  2. 不,测量协议(protocol)非常难以理解,而且在很多情况下文档也不清楚。这与你的智力无关。

提示:

  1. 您可以使用 Validateing hits 测试您的请求.
  2. 使用测量协议(protocol)跟踪配额的教程:Monitoring Quota usage for Google APIs

关于php - 在 PHP/Zend 框架中获取 Google Analytics 的 cid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30073633/

相关文章:

php - Laravel 尝试播种未要求的列

php - 在 PHP/MYSQL 中基于 DATE 的 SELECT 的最佳方式

php - 我如何在 Zend_Db_Select where() 子句中使用问号 '?'?

php - Zend Join 左警告 : Select query cannot join with another table in/var/www/myiartz/library/Zend/Db/Select. php

wordpress - 永久将域名移至子目录而不影响 SEO、Google Analytics

ios - 在发布配置中运行时,应用程序无法导入桥接 header 并找到 Google/Analytics.h

google-analytics - Google Analytics(分析)中的事件标签和类别

javascript - 如何在 CamanJS 中编辑远程图像

javascript - 为什么这在 JS 而不是 PHP 中有效?

php - NetBeans IDE 7.2 - 安装 Zend Framework