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

AnalyticsService not registered in the app manifest – error

I am not sure if acting on this warning will solve the issue you’re having (i.e. not seeing any information in the Analytics admin site). Anyway, here is what you should add to AndroidManifest.xml inside the application tag if you want to get rid of this warning: <!– Optionally, register AnalyticsReceiver and AnalyticsService to support … Read more

How do you integrate Universal Analytics in to Chrome Extensions?

There’s an issue for that on Google code: The solution is to pass analytics your own protocol check function or simply null for no checking, in an official way. This has to come after ga(‘create’, …) : ga(‘set’, ‘checkProtocolTask’, null); // Disable file protocol checking. So you don’t need to modify the original analytics.js script. … 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’); });

Is there a setting on Google Analytics to suppress use of cookies for users who have not yet given consent

EDIT (2019): The below answer predates GDPR and likely requires revision. Google Analytics has a new set of APIs to assist with compliance with a cookie opt-out. Here’s the documentation, and here’s their help docs. There has been some ambiguity as to whether the EU Cookie Regulations (as implemented in member countries) require that passive … Read more