angularanalyticsmatomoangularticsangulartics2

Angulartics2 Basics


I tried following the Angulartics2 tutorial in the project's readme, but router events are not being tracked.

First of all, I'm confused on where to drop the analytics provider script. Does that just get placed in index.html?

In my app.module.ts, I have:

import { Angulartics2Module, Angulartics2Piwik } from 'angulartics2';
@NgModule{[
    imports: [
        ...
        Angulartics2Module.forRoot([ Angulartics2Piwik ]),
        ...
    ],...
)

In my app.component.ts, I have:

import { Angulartics2Piwik } from 'angulartics2';
@Component([
    selector: "app",
    templateUrl: "app.component.html",
])
@Injectable()
export class AppComponent {
    constructor(angulartics2Piwik: Angulartics2Piwik) {}
}

And in my index.html I simply include the script provided by Piwik.

The project readme makes it seem like this is all that is needed to begin tracking router changes. However, Piwik is just seeing pageviews, not router changes.

Any idea on what I might be missing with Angulartics2?


Solution

  • The above is correct. However, in Piwik settings, the deep link tracking has to be enabled. In the UI, go to settings -> websites -> settings -> Page URL fragments tracking. Enable this and save. Your Piwik + Angulartics install should work!