2

I want to track the usage of an API. So I'm using Zend_Http_Client to send POST-parameters to Google Analytic's collector. The Google developers-page tells me, that I have to send a cid (Anonymous Client ID). But how can I send it via PHP when it is part of the _ga-cookie?

Am I supposed to create my own cid? Or am I just too dumb to understand the manual?
Thanks!

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Stephan Weinhold
  • 1,623
  • 1
  • 28
  • 37

1 Answers1

4

All of the parameters sent directly through the Measurement protocol must be created by you.

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

I normally use a GUID for this. There appears to be a PHP-function that does this: com_create_guid or maybe uniqid

Anwsers:

  1. Yes you are supposed to create your own cid.
  2. No the measurement protocol is very hard to understand and in a lot of cases the documentation isn't clear. This has nothing to do with your intelligence.

TIPs:

  1. You can test your requests using Validateing hits.
  2. Tutorial on using the Measurment protocol to track quota: Monitoring Quota usage for Google APIs
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449