Jump to content

Add Facebook pixel event on block image link

Recommended Posts

Site URL: https://storiesone.com

Hello everyone,

I am struggling to add a facebook pixel event on an image link click on squarespace. On the website it is the join Discord image, that open our Discord link and I want to be able to target people that perform this action most of the time.

First, I tried to use the No code facebook pixel event manager solution but it doesn't recognized the event when I click on the image.

Then I tried using the code injection solution but still doesn't work.

I have injected this code inspired from a stackoverflow post in the squarespace code injection header space:

<script>
(function() {
    var blockBtns = document.getElementsByClassName("sqs-block-image-link");
    for (var i = 0; i < blockBtns.length; i++) blockBtns[i].addEventListener("click", function() {
        fbq("track", "Discord Click", {
        });
    });
})();
</script>


The result is:
Just after opening the website page, I have this message on the facebook pixel helper chrome extension ( i still did not click on the Discord button)

image.png.f7633d79ca0e6330c185f151a57a4a16.png

When I click on the Discord image, nothing change on the facebook pixel helper.

If someone can help me solve that situation that would be awesome 🙂

Link to comment
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.