简体   繁体   中英

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?

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM