angulartics-facebook-pixel
angulartics-facebook-pixel copied to clipboard
Pixel keeps reporting the initial page
When moving across the pages and committing events only the initial page (the page when the fbq was initialised) is reported. angulartics-google-analytics works fine. Version 0.2.0
Hi @DamodarSojka, Thanks for your report :)
I just looked over fbevent.js scripts, and i found that facebook pixel script caches url of initial landing page internally, and it couldn't updated even browser history updated via history.pushState, history.replaceState!
Currently, There doesn't seems any CLEAN workarounds for this issue, because the origin of this behavior is internal part of facebook pixel tracking script.
If you don't mind quick-and-dirty-and-dangerous solution, Use below code. Below code monkey-patches internal part of pixel script.
fbq('init', 'YOUR_PIXEL_KEY');
// ADD BELOW CODE!
(function () {
var __pixelPatchTimerId = setInterval(function() {
if (typeof fbq.getFbeventsModules === 'function' && fbq.getFbeventsModules('SignalsParamList')) {
clearInterval(__pixelPatchTimerId);
__pixelPatchTimerId = null;
var _module = fbq.getFbeventsModules('SignalsParamList');
var _orgFn = _module.prototype.append;
_module.prototype.append = function() {
var args = Array.prototype.slice.call(arguments);
if (args[0] === 'dl') {
args[1] = location.href; // force updates location that sending to facebook
}
return _orgFn.apply(this, args);
};
}
}, 100);
})();