What is the client ID when sending tracking data to google analytics via the measurement protocol?

Integer or UUID The cid is the equivalent of the second value in the _utma cookie when you use the javascript tracking. In js tracking, it is a random integer (generated by Math.round(2147483647 * Math.random())). But it is strored and sent as a string : so you can use both formats (integer or UUID). Required/Optional … Read more

Google Analytics GIF request not sent

Are you testing your site on localhost or an intranet? If so, you may need to add _gaq.push([‘_setDomainName’, ‘none’]); before _trackPageview See Google Analytics on Intranets and Development Servers for more info… If you’re using Google Analytics on a site with a URL like http://intranet/ or something like http://mydevserver:12345 it won’t work. Specifically, the Google … Read more

PageSpeed Insights 99/100 because of Google Analytics – How can I cache GA?

Well, if Google is cheating on you, you can cheat Google back: This is the user-agent for pageSpeed: “Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.8 (KHTML, like Gecko; Google Page Speed Insights) Chrome/19.0.1084.36 Safari/536.8” You can insert a conditional to avoid serving the analytics script to PageSpeed: <?php if (!isset($_SERVER[‘HTTP_USER_AGENT’]) || stripos($_SERVER[‘HTTP_USER_AGENT’], ‘Speed Insights’) === false): ?> … Read more

How to set up Google Analytics for React-Router?

Keep a reference to your history object. i.e. import { createBrowserHistory } from ‘history’; var history = createBrowserHistory(); ReactDOM.render(( <Router history={history}> […] Then add a listener to record each pageview. (This assumes you’ve already set up the window.ga object in the usual manner.) history.listen((location) => { window.ga(‘set’, ‘page’, location.pathname + location.search); window.ga(‘send’, ‘pageview’); });

Can you test google analytics on a localhost address?

This question remains valid today, however the technology has changed. The old Urchin tracker is deprecated and obsolete. The new asynchronous Google Analytics tracking code uses slightly different code to achieve the same results. Google Analytics Classic – Asynchronous Syntax – ga.js The current syntax for setting the tracking domain to none on google analytics … Read more