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

What is the difference between google tag manager and google analytics?

Google Analytics‘ main job is really just generating the reports and statistics about your website, like how many people saw your website yesterday, what web browser they used, which pages were the most popular, etc. The only way it can know this stuff is if you put a “tag” on all of your pages. The … Read more

Tracking Google Analytics Page Views with AngularJS

If you’re using ng-view in your Angular app you can listen for the $viewContentLoaded event and push a tracking event to Google Analytics. Assuming you’ve set up your tracking code in your main index.html file with a name of var _gaq and MyCtrl is what you’ve defined in the ng-controller directive. function MyCtrl($scope, $location, $window) … 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

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

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