homepage: google.com/analytics
docs: developers.google.com/analytics/devguides/collection/analyticsjs/
import: import { Angulartics2GoogleAnalytics } from 'angulartics2';
- Add
analytics.js
tracking code provided by Google to the beginning of your body tag.
Note: If Google Analytics suggest you use
gtag.js
tracking code, either switch toanalytics.js
, or have a look at the instructions for Google Tag Manager.
- Remove
ga('send', 'pageview');
to prevent duplicate pageview (as this is also done by angulartics):
<script>
...
ga('create', 'UA-XXXXXXXX-X', 'none'); // 'none' while you are working on localhost
ga('send', 'pageview'); // DELETE THIS LINE!
</script>
- Setup Angulartics using
Angulartics2GoogleAnalytics