I've followed the instructions on the readme of Angulartics2 for Google Analytics:
app.module.ts:
import { Angulartics2Module } from 'angulartics2';
import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
...
imports: [Angulartics2Module.forRoot([Angulartics2GoogleAnalytics])
app.component.ts
import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
...
constructor(
angulartics2GoogleAnalytics: Angulartics2GoogleAnalytics
) {
angulartics2GoogleAnalytics.startTracking();
}
angulartics2GoogleAnalytics.startTracking() throws an error though: Angulartics2: startTracking() does not exist on type 'Angulartics2GoogleAnalytics'.
Can anyone tell me why? I'm using Angular 5.2.8.
Turns out RXJS 6.0.0 is required: https://github.com/angulartics/angulartics2/issues/266. I believe using RXJS 5 causes angulartics2/ga not to be found, hence the error mentioned in my question.