Provider: Mixpanel

Setup

1. Add Mixpanel Snippet

Add the tracking code provided by Mixpanel to your index.html file, typically before the closing </head> tag.

2. Configure Angulartics2

In your root component (e.g., app.component.ts), inject Angulartics2Mixpanel and call startTracking().

import { Component } from '@angular/core';
import { Angulartics2Mixpanel } from 'angulartics2';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
})
export class AppComponent {
  constructor(angulartics2Mixpanel: Angulartics2Mixpanel) {
    angulartics2Mixpanel.startTracking();
  }
}

This will activate automatic page tracking and enable other tracking methods for Mixpanel.

Specific Mixpanel Features

Angulartics2 supports several Mixpanel-specific features through its API:

  • setUsername(userId): Calls mixpanel.identify(userId).
  • setUserProperties(properties): Calls mixpanel.people.set(properties).
  • setUserPropertiesOnce(properties): Calls mixpanel.people.set_once(properties).
  • setSuperProperties(properties): Calls mixpanel.register(properties).
  • setSuperPropertiesOnce(properties): Calls mixpanel.register_once(properties).
  • setAlias(alias): Calls mixpanel.alias(alias).