Home > Paid Traffic Sources > Facebook & Instagram

Fire Facebook Pixel on Link-Click (4)


07-30-2018 02:17 PM #1 caramba (AMC Alumnus)
Fire Facebook Pixel on Link-Click

Hi guys,

I would like to fire the Facebook pixel when a visitor clicks an affiliate link on my lander to optimize the Facebook campaign for clickers not just readers and to build a lookalike audience out of these clickers.

To do so I added the following code to my Facebook pixel:

function klick() {
// Grab those link clickers!!
window._fbq.push('track', 'AddToCart');
}

so my code now looks like this:

<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=f unction(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(argum ents)};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');

fbq('init', "xxxxxxxxxxx"); // Insert your pixel ID here.
fbq('track', "PageView");

function klick() {
// Grab those link clickers!!
window._fbq.push('track', 'AddToCart');
}

</script>

<noscript>
<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=xxxxxxxxxxxx&ev=PageView&noscript=1"/>
</noscript>
<!-- End Facebook Pixel Code -->

I found the code at http://iamattila.com/media-buying-10...our-lander.php

After implementing, I checked with chromes Pixel helper if the Pixel works, but it says, that there is no Facebook pixel. In my source code I find it as posted above.

Can someone tell me if it still works, even if the Pixel helper can´t find it?


07-30-2018 04:09 PM #2 Mr Baffoe (Veteran Member)

You are missing the part that actually calls the klick() function when a link is clicked.

The best way to do that is to attach an event listener to your link. You missed step 3 in the article

Here's some extra info from the FB docs

https://developers.facebook.com/docs...use-cases/v3.1


08-01-2018 08:31 AM #3 caramba (AMC Alumnus)

Alright, thank you. I thought that the Pixel Helper ist just looking at the code if it finds the Pixel, not that it is checking if it fires.

But thinking about it, it does make more sense that it tests the events. :-D

Thank you!


08-01-2018 11:28 AM #4 diamond (Member)

The Pixel Helper looks for the pixel when you're on a page and it also observes for any events fired. If it doesn't do either, there might be something wrong with the setup.


Home > Paid Traffic Sources > Facebook & Instagram