I have enabled facebook pixel into my angular webApp. But it only works on if i hard refresh. After that the request gets triggered via service worker and not getting registered in the facebook pixel extension.
I have tried including the links into the dataGroups.
I have also tried the ngsw-bypass=true query param
Everything works fine if i remove the service worker from my app.
ngsw-config.json
{
"index": "/index.html",
"dataGroups": [
{
"name": "api",
"urls": ["https://connect.facebook.net/en_US/fbevents.js","https://connect.facebook.net/signals/config/**"],
"cacheConfig": {
"maxSize": 0,
"maxAge": "0u",
"strategy": "freshness"
}
}
],
"assetGroups": [
{
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**",
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
]
}
}
]
}
load() {
if (!this.loadOk) {
(function (f: any, b, e, v, n, t, s) {
if (f.fbq) return; n = f.fbq = function () {
n.callMethod ?
n.callMethod.apply(n, arguments) : n.queue.push(arguments)
}; if (!f._fbq) f._fbq = n;
n.push = n; n.loaded = !0; n.version = '2.0'; n.queue = []; t = b.createElement(e); t.async = !0;
t.src = v; s = b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t, s)
})(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js?ngsw-bypass=true');
// (window as any).fbq.disablePushState = true; //not recommended, but can be done
(window as any).fbq('init', '1117176809040790');
(window as any).fbq('track', 'PageView');
this.loadOk = true;
console.log('Facebook pixel init run!')
}
else {
(window as any).fbq('track', 'PageView');
console.log('Facebook PageView event fired!')
}
}