You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+59-3Lines changed: 59 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,11 @@ Using a Facebook Pixel is fairly simple. You add the script to the `head` sectio
14
14
- Navigation using the Angular Router is not tracked.
15
15
- There are no TypeScript definitions by default, so no Intellisense or linting.
16
16
17
-
***ngx-pixel*** solves both of these issues.
17
+
***ngx-pixel*** solves both of these issues. It adds a service that can be used in any component to track events and when enabled, it automatically tracks page views for each router navigation.
18
+
19
+
By default, ***ngx-pixel*** is **disabled** to make it easier to comply with GDPR and other privacy regulations. The Facebook script is only loaded after ***ngx-pixel*** is enabled, which also helps cut down the initial load time of your application. Read [here](#enabling) how to *enable* and *disable****ngx-pixel***.
## Enabling and disabling ***ngx-pixel*** <aname="enabling"></a>
94
+
***ngx-pixel*** is disabled by default. In many cases, tracking without user consent is not allowed by privacy regulations like the European GDPR. ***ngx-pixel*** also doesn't inject the Facebook scripts until it is iniaitlized (upon consent), which helps cut down the initial loading size and time of your application.
95
+
96
+
### Enabling ***ngx-pixel*** immediately
97
+
It is still possible to initialize ***ngx-pixel*** as soon as your app module loads.
98
+
When adding ***ngx-pixel*** to `app.module.ts`, add the parameter `enabled: true`.
You can also enable ***ngx-pixel*** from within any of your components, like so:
108
+
```TypeScript
109
+
exportclassHomeComponent {
110
+
111
+
constructor(
112
+
privatepixel:PixelService
113
+
) { }
114
+
115
+
onConsent():void {
116
+
this.pixel.initialize();
117
+
}
118
+
119
+
}
120
+
```
121
+
122
+
### Disabling ***ngx-pixel***
123
+
Disabling works very similar to *enabling* from within a component and looks like this:
124
+
```TypeScript
125
+
exportclassHomeComponent {
126
+
127
+
constructor(
128
+
privatepixel:PixelService
129
+
) { }
130
+
131
+
onRevokeConsent():void {
132
+
this.pixel.remove();
133
+
}
134
+
135
+
}
136
+
```
137
+
138
+
---
139
+
87
140
## Important notes
88
-
-***ngx-pixel*** was developed using Angular 11, which uses the Ivy compiler instead of the older View Engine compiler. If your project uses Angular 8 or earlier, or if you decided to keep using View Engine with newer Angular versions, ***ngx-pixel*** might not be compatible, although I have not yet tested this to confirm.
141
+
- Backwards compatibility is not guaranteed. ***ngx-pixel*** was developed using Angular 11, which uses the Ivy compiler instead of the older View Engine compiler. If your project uses Angular 8 or earlier, or if you decided to keep using View Engine with newer Angular versions, ***ngx-pixel*** might not be compatible, although I have not yet tested this to confirm.
142
+
143
+
---
89
144
90
145
## What's next?
91
-
-[ ] Checking Pixel ID's using a RegEx. I first want to confirm whether all Pixel ID's follow the same format.
146
+
-[ ] Checking Pixel ID's using a RegEx. First need to confirm whether all Pixel ID's follow the same format.
92
147
-[ ] Adding tests.
93
148
-[ ] Testing View Engine backwards-compatibility.
149
+
-[ ] Removing all Facebook scripts on removal, not just the initial script.
0 commit comments