Demo

To view the result open up the console or Charles and check the network requests to see the data that is send. The trackingManager uses debug to log. Open up the console and paste in the following to view the TaskLoader events.

localStorage.debug = 'trackingManager:*'
# Provider Api loaded TrackEvent TrackPageView

Note: Some providers will not work because they will only work with valid tracking id's or urls

Logs

Code

The tracking manager is a wrapper class that you can add tracking providers to to make page tracking a little bit more organized.

The easiest way to enable it is create a tracking manager instance and provide your desired tracking providers

const trackingManager = new TrackingManager({
  providers: {
    ga: new GoogleAnalyticsTrackingProvider({
      trackingId: 'UA-XXXXXXX',
    }),
    fbq: new FacebookTrackingPixelProvider({
      : 'XXXXXXXXXX',
    }),
  }
 });

After this you can trigger the tracking events on your tracking manager

trackingManager.trackEvent({
  ga: {
    label: 'Purchase',
    category: 'shop'
  },
  fbq: {
    event: 'Purchase',
  },
});