Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tracking pixel with Angular.js

We are using facebook tracking pixel, to track the performance of our facebook ads. To do so, for every user that comes to our service for the first time we need to fire tracking pixel in DOM. We do it by setting $scope.newReg to true in controller and with following code in template.

<div ng-if="newReg == true">
<img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?ev=xxxxxx&amp;cd[value]=0.00&amp;cd[currency]=EUR&amp;noscript=1" />
</div>

The question is what is really going on if $scope.newReg is set to false. I guess that tracking pixel should'n be fired, but according to documentation it seems like it can be fired. "If condition is falsy then the element is removed from the DOM tree." Which means that tracking pixel could for a very short moment appear in the DOM and then being removed. And that would fire tracking counter even if condition fails.

like image 268
Ladislav M Avatar asked Sep 30 '22 16:09

Ladislav M


1 Answers

Nobody else dealing with this issue?

This answer seems to be working for me: Facebook Custom Audience pixel on SinglePageApplication SPA

But I believe that there are more ways how to handle it.

like image 68
Ladislav M Avatar answered Oct 03 '22 02:10

Ladislav M