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’); });

Analytics Google API Error 403: “User does not have any Google Analytics Account”

I had this problem too. I fixed it by adding the email address for my service account to the Google Analytics profile I wanted it to access. I got the email address (something like xxxxxx@developer.gserviceaccount.com) for the service account by looking under the “API Access” tab in the Google APIs console. Then, I followed Google’s … Read more

Best place to insert the Google Analytics code [duplicate]

Google used to recommend putting it just before the </body> tag, because the original method they provided for loading ga.js was blocking. The newer async syntax, though, can safely be put in the head with minimal blockage, so the current recommendation is just before the </head> tag. <head> will add a little latency; in the … Read more

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)