Skip to content

Latest commit

 

History

History
 
 

segment

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Segment logo

Segment

homepage: segment.com
docs: segment.com/docs/sources/website/analytics.js
import: import { Angulartics2Segment } from 'angulartics2';

Setup

  1. Add Angulartics2Module to your root NgModule passing an array of providers to enable
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule, Routes } from '@angular/router';

import { Angulartics2Module } from 'angulartics2';
import { Angulartics2Segment } from 'angulartics2';

const ROUTES: Routes = [
  { path: '',      component: HomeComponent },
  { path: 'about', component: AboutComponent },
];

@NgModule({
  imports: [
    BrowserModule,
    RouterModule.forRoot(ROUTES),

    // added to imports
    Angulartics2Module.forRoot([Angulartics2Segment]),
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
  1. Required: Import your providers in the root component. This starts the tracking of route changes.
// component
import { Angulartics2Segment } from 'angulartics2';

@Component({  ...  })
export class AppComponent {
  constructor(angulartics2Segment: Angulartics2Segment) {
    angulartics2Segment.startTracking();
  }
}