angulartics2 13.0.0 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +2 -1
  2. package/angulartics2On.d.ts +1 -1
  3. package/esm2020/angular-router.mjs +4 -4
  4. package/esm2020/angulartics2-core.mjs +4 -4
  5. package/esm2020/angulartics2.module.mjs +5 -5
  6. package/esm2020/angulartics2On.mjs +8 -8
  7. package/esm2020/providers/adobeanalytics/adobeanalytics.mjs +4 -4
  8. package/esm2020/providers/amplitude/amplitude.mjs +4 -4
  9. package/esm2020/providers/appinsights/appinsights.mjs +4 -4
  10. package/esm2020/providers/baidu/baidu.mjs +4 -4
  11. package/esm2020/providers/clicky/clicky.mjs +4 -4
  12. package/esm2020/providers/facebook/facebook.mjs +4 -4
  13. package/esm2020/providers/ga/ga.mjs +4 -4
  14. package/esm2020/providers/ga-enhanced-ecom/ga-enhanced-ecom.mjs +4 -4
  15. package/esm2020/providers/gosquared/gosquared.mjs +4 -4
  16. package/esm2020/providers/gst/gst.mjs +4 -4
  17. package/esm2020/providers/gtm/gtm.mjs +4 -4
  18. package/esm2020/providers/hubspot/hubspot.mjs +4 -4
  19. package/esm2020/providers/ibm-digital-analytics/ibm-digital-analytics.mjs +4 -4
  20. package/esm2020/providers/intercom/intercom.mjs +4 -4
  21. package/esm2020/providers/kissmetrics/kissmetrics.mjs +4 -4
  22. package/esm2020/providers/launch/launch.mjs +4 -4
  23. package/esm2020/providers/matomo/matomo.mjs +4 -4
  24. package/esm2020/providers/mixpanel/mixpanel.mjs +4 -4
  25. package/esm2020/providers/posthog/posthog.mjs +117 -0
  26. package/esm2020/providers/pyze/pyze.mjs +4 -4
  27. package/esm2020/providers/segment/segment.mjs +4 -4
  28. package/esm2020/providers/splunk/splunk.mjs +4 -4
  29. package/esm2020/providers/woopra/woopra.mjs +4 -4
  30. package/esm2020/public_api.mjs +2 -1
  31. package/esm2020/routerless.module.mjs +5 -5
  32. package/fesm2015/angulartics2.mjs +203 -89
  33. package/fesm2015/angulartics2.mjs.map +1 -1
  34. package/fesm2020/angulartics2.mjs +203 -89
  35. package/fesm2020/angulartics2.mjs.map +1 -1
  36. package/package.json +3 -3
  37. package/providers/posthog/posthog.d.ts +20 -0
  38. package/public_api.d.ts +1 -0
  39. package/providers/adobeanalytics/README.md +0 -12
  40. package/providers/amplitude/README.md +0 -12
  41. package/providers/appinsights/README.md +0 -12
  42. package/providers/baidu/README.md +0 -12
  43. package/providers/clicky/README.md +0 -93
  44. package/providers/facebook/README.md +0 -36
  45. package/providers/ga/README.md +0 -25
  46. package/providers/ga-enhanced-ecom/README.md +0 -12
  47. package/providers/gosquared/README.md +0 -12
  48. package/providers/gst/README.md +0 -110
  49. package/providers/gtm/README.md +0 -58
  50. package/providers/hubspot/README.md +0 -12
  51. package/providers/ibm-digital-analytics/README.md +0 -123
  52. package/providers/incendium/README.md +0 -100
  53. package/providers/intercom/README.md +0 -12
  54. package/providers/kissmetrics/README.md +0 -12
  55. package/providers/launch/README.md +0 -59
  56. package/providers/matomo/README.md +0 -74
  57. package/providers/mixpanel/README.md +0 -105
  58. package/providers/pyze/README.md +0 -21
  59. package/providers/segment/README.md +0 -50
  60. package/providers/splunk/README.md +0 -57
  61. package/providers/woopra/README.md +0 -12
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "angulartics2",
3
3
  "description": "Vendor-agnostic web analytics for Angular2 applications",
4
- "version": "13.0.0",
4
+ "version": "14.0.0",
5
5
  "release": {
6
6
  "branch": "master"
7
7
  },
@@ -32,8 +32,8 @@
32
32
  "pyze"
33
33
  ],
34
34
  "peerDependencies": {
35
- "@angular/common": ">=14.0.0-0",
36
- "@angular/core": ">=14.0.0-0",
35
+ "@angular/common": ">=15.0.0-0",
36
+ "@angular/core": ">=15.0.0-0",
37
37
  "rxjs": "^7.4.0"
38
38
  },
39
39
  "module": "fesm2015/angulartics2.mjs",
@@ -0,0 +1,20 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare class Angulartics2Posthog {
3
+ private readonly angulartics2;
4
+ constructor();
5
+ startTracking(): void;
6
+ startPageTracking(): void;
7
+ startEventTracking(): void;
8
+ pageTrack(path: string | undefined): void;
9
+ eventTrack(action: string, properties?: any): void;
10
+ setUsername(userId: string | {
11
+ userId: string | number;
12
+ }): void;
13
+ setUserProperties(properties: any | undefined): void;
14
+ setUserPropertiesOnce(properties: any | undefined): void;
15
+ setSuperProperties(properties: any | undefined): void;
16
+ setSuperPropertiesOnce(properties: any | undefined): void;
17
+ setAlias(alias: string): void;
18
+ static ɵfac: i0.ɵɵFactoryDeclaration<Angulartics2Posthog, never>;
19
+ static ɵprov: i0.ɵɵInjectableDeclaration<Angulartics2Posthog>;
20
+ }
package/public_api.d.ts CHANGED
@@ -19,6 +19,7 @@ export * from './providers/hubspot/hubspot';
19
19
  export * from './providers/kissmetrics/kissmetrics';
20
20
  export * from './providers/launch/launch';
21
21
  export * from './providers/mixpanel/mixpanel';
22
+ export * from './providers/posthog/posthog';
22
23
  export * from './providers/pyze/pyze';
23
24
  export * from './providers/matomo/matomo';
24
25
  export * from './providers/segment/segment';
@@ -1,12 +0,0 @@
1
- <img
2
- src="../../../assets/svg/adobeanalytics.svg"
3
- alt="Adobe Analytics Cloud logo"
4
- height="100px"
5
- width="200px" />
6
-
7
- # Adobe Analytics Cloud
8
- __homepage__: [adobe.com/data-analytics-cloud/analytics.html](http://www.adobe.com/data-analytics-cloud/analytics.html)
9
- __docs__: [marketing.adobe.com/resources/help/en_US/sc/implement/impl_js_file.html](https://marketing.adobe.com/resources/help/en_US/sc/implement/impl_js_file.html)
10
- __import__: `import { Angulartics2AdobeAnalytics } from 'angulartics2';`
11
-
12
- ## Setup
@@ -1,12 +0,0 @@
1
- <img
2
- src="../../../assets/svg/amplitude.svg"
3
- alt="Amplitude logo"
4
- height="100px"
5
- width="200px" />
6
-
7
- # Amplitude
8
- __homepage__: [www.amplitude.com](https://www.amplitude.com/)
9
- __docs__: [amplitude.zendesk.com/hc](https://amplitude.zendesk.com/hc)
10
- __import__: `import { Angulartics2Amplitude } from 'angulartics2';`
11
-
12
- ## Setup
@@ -1,12 +0,0 @@
1
- <img
2
- src="../../../assets/svg/appinsights.svg"
3
- alt="Microsoft Application Insights logo"
4
- height="100px"
5
- width="200px" />
6
-
7
- # Microsoft Application Insights
8
- __homepage__: [azure.microsoft.com/en-us/services/application-insights/](https://azure.microsoft.com/en-us/services/application-insights/)
9
- __docs__: [github.com/Microsoft/ApplicationInsights-JS](https://github.com/Microsoft/ApplicationInsights-JS#microsoft-application-insights-javascript-sdk)
10
- __import__: `import { Angulartics2AppInsights } from 'angulartics2';`
11
-
12
- ## Setup
@@ -1,12 +0,0 @@
1
- <img
2
- src="../../../assets/svg/baidu.svg"
3
- alt="Baidu logo"
4
- height="100px"
5
- width="200px" />
6
-
7
- # Baidu
8
- __homepage__: [tongji.baidu.com/web/welcome/login](https://tongji.baidu.com/web/welcome/login)
9
- __docs__: ???
10
- __import__: `import { Angulartics2BaiduAnalytics } from 'angulartics2';`
11
-
12
- ## Setup
@@ -1,93 +0,0 @@
1
- <img
2
- src="../../../assets/svg/clicky.svg"
3
- alt="Clicky logo"
4
- height="100px"
5
- width="200px" />
6
-
7
- # Clicky
8
- __homepage__: [clicky.com](https://clicky.com/)
9
- __docs__: [clicky.com/help/](https://clicky.com/help/)
10
- __import__: `import { Angulartics2Clicky } from 'angulartics2';`
11
-
12
- ## Setup
13
-
14
- Add the following clicky code to your *index.html* file, before the closing body tag. Replace *XXXX* with your Clicky Site ID.
15
-
16
- ```html
17
- <script type="text/javascript">
18
- var clicky_custom = {
19
- pageview_disable : 1,
20
- history_disable : 1
21
- };
22
- </script>
23
- <script src="//static.getclicky.com/js" type="text/javascript"></script>
24
- <script type="text/javascript">try{ clicky.init(XXXXX); }catch(e){}</script>
25
- ```
26
-
27
- ## Usage
28
-
29
- ### Import
30
- ```ts
31
- // app.module.ts
32
- import { BrowserModule } from '@angular/platform-browser';
33
- import { NgModule } from '@angular/core';
34
- import { RouterModule, Routes, RouterOutlet } from '@angular/router';
35
-
36
- import { AppComponent } from './app.component';
37
-
38
- import { Angulartics2Module } from 'angulartics2';
39
- import { PageComponent } from './page/page.component';
40
- import { HomeComponent } from './home/home.component';
41
-
42
- const ROUTES: Routes = [
43
- { path: '', component: HomeComponent},
44
- { path: 'page', component: PageComponent}
45
- ];
46
-
47
- @NgModule({
48
- declarations: [
49
- AppComponent,
50
- PageComponent,
51
- HomeComponent
52
- ],
53
- imports: [
54
- BrowserModule,
55
- RouterModule.forRoot(ROUTES),
56
- Angulartics2Module.forRoot()
57
- ],
58
- providers: [],
59
- bootstrap: [AppComponent]
60
- })
61
- export class AppModule { }
62
- ```
63
-
64
- ### Enable Auto Route Logging
65
- ```ts
66
- // app.component.ts
67
- import { Component } from '@angular/core';
68
- import { Angulartics2Clicky } from 'angulartics2-clicky';
69
-
70
- @Component({
71
- selector: 'app-root',
72
- templateUrl: './app.component.html',
73
- styleUrls: ['./app.component.css']
74
- })
75
- export class AppComponent {
76
- // Enable auto route logging
77
- constructor(angulartics2Clicky: Angulartics2Clicky) {
78
- angulartics2Clicky.startTracking();
79
- }
80
- }
81
- ```
82
-
83
- ### Track Events & Goals
84
- ```html
85
- <li>
86
- <!-- Track Events -->
87
- <button angulartics2On="click" angularticsAction="event-button" [angularticsProperties]="{title: 'Event Button Clicked'}">Track Button Click Event 1</button>
88
- </li>
89
- <li>
90
- <!-- Track Goals -->
91
- <button angulartics2On="click" angularticsAction="event-button" [angularticsProperties]="{goal: 'Goal #1', revenue: 500, noQueue: true}">Goal Button</button>
92
- </li>
93
- ```
@@ -1,36 +0,0 @@
1
- <img
2
- src="../../../assets/svg/facebook.svg"
3
- alt="Facebook Pixel logo"
4
- height="100px"
5
- width="200px" />
6
-
7
- # Facebook Pixel
8
-
9
- __homepage__: [www.facebook.com/business/a/facebook-pixel](https://www.facebook.com/business/a/facebook-pixel)
10
- __docs__: [developers.facebook.com/docs/facebook-pixel](https://developers.facebook.com/docs/facebook-pixel)
11
- __import__: `import { Angulartics2Facebook } from 'angulartics2';`
12
-
13
- ## Setup
14
-
15
- 1. Add tracking code [provided by Facebook](https://www.facebook.com/events_manager/)
16
- ```html
17
- <!-- Facebook Pixel Code -->
18
- <script>
19
- !function(f,b,e,v,n,t,s)
20
- {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
21
- n.callMethod.apply(n,arguments):n.queue.push(arguments)};
22
- if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
23
- n.queue=[];t=b.createElement(e);t.async=!0;
24
- t.src=v;s=b.getElementsByTagName(e)[0];
25
- s.parentNode.insertBefore(t,s)}(window, document,'script',
26
- 'https://connect.facebook.net/en_US/fbevents.js');
27
- fbq('init', 'XXXXXXXXXXXXXXX');
28
- fbq('track', 'PageView');
29
- </script>
30
- <noscript><img height="1" width="1" style="display:none"
31
- src="https://www.facebook.com/tr?id=XXXXXXXXXXXXXXX&ev=PageView&noscript=1"
32
- /></noscript>
33
- <!-- End Facebook Pixel Code -->
34
- ```
35
- 2. Do **not** remove the pageview tracking (as you would to for Google Analytics)
36
- 3. [Setup Angulartics](https://github.com/angulartics/angulartics2/tree/next#installation) using `Angulartics2Facebook`
@@ -1,25 +0,0 @@
1
- <img
2
- src="../../../assets/svg/ga.svg"
3
- alt="google analytics logo"
4
- height="100px"
5
- width="200px" />
6
-
7
- # Google Analytics (`analytics.js`)
8
-
9
- __homepage__: [google.com/analytics](https://www.google.com/analytics)
10
- __docs__: [developers.google.com/analytics/devguides/collection/analyticsjs/](https://developers.google.com/analytics/devguides/collection/analyticsjs/)
11
- __import__: `import { Angulartics2GoogleAnalytics } from 'angulartics2';`
12
-
13
- ## Setup
14
-
15
- 1. Add [`analytics.js` tracking code provided by Google](https://developers.google.com/analytics/devguides/collection/analyticsjs/) to the beginning of your body tag.
16
- > Note: If Google Analytics suggest you use `gtag.js` tracking code, either switch to `analytics.js`, or have a look at the instructions for [Google Tag Manager](/src/lib/providers/gtm).
17
- 2. Remove `ga('send', 'pageview');` to prevent duplicate pageview (as this is also done by angulartics):
18
- ```html
19
- <script>
20
- ...
21
- ga('create', 'UA-XXXXXXXX-X', 'none'); // 'none' while you are working on localhost
22
- ga('send', 'pageview'); // DELETE THIS LINE!
23
- </script>
24
- ```
25
- 3. [Setup Angulartics](https://github.com/angulartics/angulartics2/tree/master#installation) using `Angulartics2GoogleAnalytics`
@@ -1,12 +0,0 @@
1
- <img
2
- src="../../../assets/svg/ga.svg"
3
- alt="google analytics logo"
4
- height="100px"
5
- width="200px" />
6
-
7
- # Google Analytics Enhanced Ecommerce
8
- __homepage__: [google.com/analytics](https://www.google.com/analytics)
9
- __docs__: [developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce](https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce)
10
- __import__: `import { Angulartics2GoogleAnalyticsEnhancedEcommerce } from 'angulartics2';`
11
-
12
- ## Setup
@@ -1,12 +0,0 @@
1
- <img
2
- src="../../../assets/svg/gosquared.svg"
3
- alt="GoSquared logo"
4
- height="100px"
5
- width="200px" />
6
-
7
- # GoSquared
8
- __homepage__: [www.gosquared.com](https://www.gosquared.com/)
9
- __docs__: [gosquared.com/docs](https://gosquared.com/docs)
10
- __import__: `import { Angulartics2GoSquared } from 'angulartics2';`
11
-
12
- ## Setup
@@ -1,110 +0,0 @@
1
- <img
2
- src="../../../assets/svg/gtm.svg"
3
- alt="Google Global Site Tag logo"
4
- height="100px"
5
- width="200px" />
6
-
7
- # Google Global Site Tag (`gtag.js`)
8
-
9
- * __homepage__: [google.com/analytics](https://marketingplatform.google.com/about/analytics/)
10
- * __docs__: [developers.google.com/analytics/devguides/collection/gtagjs](https://developers.google.com/analytics/devguides/collection/gtagjs/)
11
- * __import__: `import { Angulartics2GoogleGlobalSiteTag } from 'angulartics2';`
12
-
13
- ## Initial Setup
14
-
15
- Add the full tracking code from [developers.google.com/analytics/devguides/collection/gtagjs/](https://developers.google.com/analytics/devguides/collection/gtagjs/)
16
-
17
- ## Include it in your application
18
-
19
- Bootstrapping the application with ```Angulartics2```:
20
-
21
- ```ts
22
- // bootstrap
23
- import { Angulartics2Module } from 'angulartics2';
24
-
25
- @NgModule({
26
- imports: [
27
- ...
28
- // import Angulartics2GoogleGlobalSiteTag in root ngModule
29
- Angulartics2Module.forRoot()
30
- ],
31
- })
32
- export class AppModule { }
33
- ```
34
-
35
- Then injecting `Angulartics2GoogleGlobalSiteTag` (or any provider) into the root
36
- component and calling `startTracking` will hook into the router and send every route
37
- change to your analytics provider.
38
-
39
- ```ts
40
- // component
41
- import { Angulartics2GoogleGlobalSiteTag } from 'angulartics2';
42
-
43
- @Component({ ... })
44
- export class AppComponent {
45
- // import Angulartics2GoogleGlobalSiteTag in root component
46
- constructor(angulartics: Angulartics2GoogleGlobalSiteTag) {
47
- angulartics.startTracking();
48
- }
49
- }
50
- ```
51
-
52
- ## Send tracking events in a component or template
53
-
54
- _Check out the documentation for [Tracking Events](https://github.com/angulartics/angulartics2/wiki/Tracking-Events)._
55
-
56
- ## Extended Event properties.
57
-
58
- All extended properties that can be added to events, for e-commerce (`items`, `shipping`, `tax`...), adwords (`send_to`, `account_type`, `transaction_id`) and another can be passed through the gstCustom:
59
-
60
- ```ts
61
- constructor(private angulartics2: Angulartics2) {
62
- angulartics2.eventTrack.next({
63
- action: 'conversion',
64
- properties: {
65
- gstCustom: {
66
- send_to: 'AW-XXXXXX/R-12345678',
67
- transaction_id: ''
68
- }
69
- }
70
- });
71
- }
72
- ```
73
-
74
- ## Custom dimension and tracker settings
75
-
76
- `custom_map` and other config settings you could set inside your HTML page will be overridden after each pagetrack. Therefore, you need to pass them to the GST configuration if you want to use them. At this point, you're probably better to remove completely the `gtag('config'` call from you HTML page and to add all required properties at module definition.
77
-
78
- ```ts
79
- // bootstrap
80
- import { Angulartics2Module } from 'angulartics2';
81
-
82
- @NgModule({
83
- imports: [
84
- ...
85
- // import Angulartics2GoogleGlobalSiteTag in root ngModule
86
- Angulartics2Module.forRoot(
87
- gst: {
88
- trackingIds: ['UA-11111111-1'],
89
- customMap: {
90
- dimension1: 'version',
91
- dimension2: 'page_language',
92
- dimension3: 'custom_dimension_name'
93
- },
94
- anonymizeIp: true
95
- },
96
- )
97
- ],
98
- })
99
- export class AppModule { }
100
- ```
101
-
102
- Then, you can use the normal angulartic approach:
103
-
104
- ```ts
105
- this.angulartics2.setUserProperties.next({
106
- custom_dimension_name: 'example'
107
- });
108
- ```
109
-
110
- You can also pass custom dimension with a specific event using the `gstCustom` property described in previous section
@@ -1,58 +0,0 @@
1
- <img
2
- src="../../../assets/svg/gtm.svg"
3
- alt="Google Tag Manager logo"
4
- height="100px"
5
- width="200px" />
6
-
7
- # Google Tag Manager (`gtag.js`)
8
- __homepage__: [google.com/analytics/tag-manager](https://www.google.com/analytics/tag-manager/)
9
- __docs__: [developers.google.com/tag-manager/devguide](https://developers.google.com/tag-manager/devguide)
10
- __import__: `import { Angulartics2GoogleTagManager } from 'angulartics2';`
11
-
12
-
13
- ## Initial Setup
14
-
15
- Add the full tracking code from Google Tag Manager to the beginning of your body tag.
16
-
17
- ## Include it in your application
18
-
19
- Bootstrapping the application with ```Angulartics2``` as provider and injecting both ```Angulartics2``` and ```Angulartics2GoogleTagManager``` (or any provider) into the root component will hook into the router and send every route change to your analytics provider.
20
-
21
-
22
- ```ts
23
- // component
24
- import { Angulartics2GoogleTagManager } from 'angulartics2';
25
-
26
- @Component({ ... })
27
- export class AppComponent {
28
- // import Angulartics2GoogleTagManager in root component
29
- constructor(angulartics2GoogleTagManager: Angulartics2GoogleTagManager) {
30
- angulartics2GoogleTagManager.startTracking();
31
- }
32
- }
33
- ```
34
-
35
- ```ts
36
- // bootstrap
37
- import { Angulartics2Module } from 'angulartics2';
38
-
39
- @NgModule({
40
- imports: [
41
- ...
42
- // import Angulartics2GoogleTagManager in root ngModule
43
- Angulartics2Module.forRoot()
44
- ],
45
- })
46
- ```
47
-
48
- ### Setting Up Tags
49
-
50
- Now is the time to setup tracking for the tags in GTM. [Here is a great post](http://blog.thecodecampus.de/angular-2-google-analytics-google-tag-manager/) on how to actually perform this setup. In essence here is the TLDR:
51
-
52
- 1. Create a new tag
53
- 2. Add Universal Analytics + Tracking ID from GA
54
- 3. Create a new "Fire On" trigger (Custom Event) that tracks the `Page View` (for `pageTrack()`)
55
-
56
- Make sure to debug it :D
57
-
58
- ### _For detailed instructions on how to send tracking events in a component or in a template check out the documentation for [Tracking Events](https://github.com/angulartics/angulartics2/wiki/Tracking-Events)._
@@ -1,12 +0,0 @@
1
- <img
2
- src="../../../assets/svg/hubspot.svg"
3
- alt="HubSpot logo"
4
- height="100px"
5
- width="200px" />
6
-
7
- # HubSpot
8
- __homepage__: [www.hubspot.com](https://www.hubspot.com/)
9
- __docs__: [developers.hubspot.com/docs/methods/tracking_code_api/tracking_code_overview](https://developers.hubspot.com/docs/methods/tracking_code_api/tracking_code_overview)
10
- __import__: `import { Angulartics2Hubspot } from 'angulartics2';`
11
-
12
- ## Setup
@@ -1,123 +0,0 @@
1
- <img
2
- src="../../../assets/svg/ibm.svg"
3
- alt="IBM logo"
4
- height="300px"
5
- width="400px" />
6
-
7
- # IBM Digital Analytics
8
- __homepage__: [https://digitalanalytics.ibmcloud.com](https://digitalanalytics.ibmcloud.com)
9
- __docs__: [https://www.ibm.com/support/knowledgecenter/SSPG9M/Analytics/kc_welcome_analytics.html](https://www.ibm.com/support/knowledgecenter/SSPG9M/Analytics/kc_welcome_analytics.html)
10
- __import__: `import { Angulartics2IBMDigitalAnalytics } from 'angulartics2';`
11
-
12
- ## Setup
13
-
14
- Add the following IBM Digital Analytics code to your *index.html* file, before the closing body tag. Replace *XXXXXXXXX* with your Client ID and other *cmSetClientID* function parameters accordingly.
15
-
16
- ```html
17
- <script type="text/javascript" src="//libs.coremetrics.com/eluminate.js"></script>
18
- <script type="text/javascript">
19
- cmSetClientID("XXXXXXXXX", true, "data.coremetrics.com", "ibm.com");
20
- </script>
21
-
22
- ```
23
-
24
- ## Usage
25
-
26
- ### Import
27
- ```ts
28
- // app.module.ts
29
- import { BrowserModule } from '@angular/platform-browser';
30
- import { NgModule } from '@angular/core';
31
- import { RouterModule, Routes, RouterOutlet } from '@angular/router';
32
-
33
- import { AppComponent } from './app.component';
34
-
35
- import { Angulartics2Module } from 'angulartics2';
36
- import { PageComponent } from './page/page.component';
37
- import { HomeComponent } from './home/home.component';
38
-
39
- const ROUTES: Routes = [
40
- { path: '', component: HomeComponent},
41
- { path: 'page', component: PageComponent}
42
- ];
43
-
44
- @NgModule({
45
- declarations: [
46
- AppComponent,
47
- PageComponent,
48
- HomeComponent
49
- ],
50
- imports: [
51
- BrowserModule,
52
- RouterModule.forRoot(ROUTES),
53
- Angulartics2Module.forRoot()
54
- ],
55
- providers: [],
56
- bootstrap: [AppComponent]
57
- })
58
- export class AppModule { }
59
- ```
60
-
61
- ### Enable Auto Route Logging
62
- ```ts
63
- // app.component.ts
64
- import { Component } from '@angular/core';
65
- import { Angulartics2IBMDigitalAnalytics } from 'angulartics2';
66
-
67
- @Component({
68
- selector: 'app-root',
69
- templateUrl: './app.component.html',
70
- styleUrls: ['./app.component.css']
71
- })
72
- export class AppComponent {
73
- // Enable route logging
74
- constructor(angulartics2IBMDigitalAnalytics: Angulartics2IBMDigitalAnalytics) {
75
- angulartics2IBMDigitalAnalytics.startTracking();
76
- }
77
- }
78
- ```
79
-
80
- ### Track Events in Template
81
- ```html
82
- <div
83
- angulartics2On="click"
84
- angularticsAction="cmCreateProductviewTag"
85
- [angularticsProperties]="{'productId': '123', 'productName': 'Apples', 'categoryId': '777'}"
86
- >Click Me for cmCreateProductviewTag</div>
87
-
88
- <div
89
- angulartics2On="click"
90
- angularticsAction="cmCreateShopAction5Tag"
91
- [angularticsProperties]="{'productId': '124', 'productName': 'Pears', 'quantity': '5', 'unitPrice': '1.99', 'categoryId': '778'}"
92
- >Click Me for cmCreateShopAction5Tag</div>
93
-
94
- <div
95
- angulartics2On="click"
96
- angularticsAction="cmCreateShopAction9Tag"
97
- [angularticsProperties]="{'productId': '125', 'productName': 'Apricots', 'quantity': '6', 'unitPrice': '2.99', 'registrationId': '123456', 'orderId': '456', 'orderSubtotal': '29.90', 'categoryId': '779'}"
98
- >Click Me for cmCreateShopAction9Tag</div>
99
-
100
- <div
101
- angulartics2On="click"
102
- angularticsAction="cmCreateOrderTag"
103
- [angularticsProperties]="{'orderId': '456', 'orderSubtotal': '29.90', 'orderShipping': '0', 'registrationId': '123456', 'registrantCity': 'Atlanta', 'registrantState': 'GA', 'registrantPostalCode': '30300'}"
104
- >Click Me for cmCreateOrderTag</div>
105
-
106
- <div
107
- angulartics2On="click"
108
- angularticsAction="cmCreateRegistrationTag"
109
- [angularticsProperties]="{'registrationId': '123456', 'registrantEmail': 'john@example.com', 'registrantCity': 'Atlanta', 'registrantState': 'GA', 'registrantPostalCode': '30300', 'registrantCountry': 'US', 'attrbute': '3-_-SMOKING-_-DOUBLE'}"
110
- >Click Me for cmCreateRegistrationTag</div>
111
-
112
- <div
113
- angulartics2On="click"
114
- angularticsAction="cmCreateElementTag"
115
- [angularticsProperties]="{'elementId': 'element123456', 'elementCategory': 'some elements'}"
116
- >Click Me for cmCreateElementTag</div>
117
-
118
- <div
119
- angulartics2On="click"
120
- angularticsAction="cmCreateConversionEventTag"
121
- [angularticsProperties]="{'eventId': 'Request More Information', 'actionType': '2', 'eventCategoryId': 'Forms', 'points': '10'}"
122
- >Click Me for cmCreateConversionEventTag</div>
123
- ```