irazasyed / laravel-gamp

📊 Laravel Google Analytics Measurement Protocol Package
https://bit.ly/laravel-gamp
MIT License
332 stars 33 forks source link

How to get client id? #6

Closed ALTELMA closed 8 years ago

ALTELMA commented 8 years ago

Sorry for newbie question. I try to get from session or cookie not work. Can you advice me to get it, please.

irazasyed commented 8 years ago

Please refer: https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#cid

Not sure from where you're trying to access the client ID but that can be set using a random generated UUID. Refer the docs above.

ALTELMA commented 8 years ago

for this "setClientId()" Where can I get it?

Now I get from javascript var clientId = tracker.get('clientId');

I don't know. please example to get it, please.

irazasyed commented 8 years ago

You don't get that. You need to set a random generated ID. Even the JS version of Google Analytics simply generates a random number for that browser session and stores that in a cookie to send hits later.

Go through the above link i sent you and this one to understand: https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id

So the example would be:

$gamp = GAMP::setClientId( '<randomly generated id>' );
$gamp->setDocumentPath( '/page' );
$gamp->sendPageview();