Search code examples
angularmixpanel

How to import mixpanel to Angular 2 + CLI project


I'm using Angular 2+ and Angular CLI.

How do I add Mixpanel to my project?


Solution

  • The title should be 'How to use Third party/vendor library with angular2'

    Suppose the api script is mixpanel.js modifiy src/app/vendors.ts to import it :

    import 'mixpanel';
    

    then your ts file :

    import * from 'mixpanel' as mixpanel;
    

    then use it using func calls like this :

    mixpanel.function1() ... 
    

    or You can use a wrapper like angulartics2 : https://github.com/angulartics/angulartics2