-
AuthorPosts
-
July 10, 2018 at 11:17 pm #983897
Hi Support,
I’ve put the facebook pixel into the child theme’s header.php.
Now I wish to put this one on my portfoliopage ( https://mindventure.dk/mindventures/lakedistrict/ ) , so when a customer enters this page, Facebook ads manager will let me know:
<script>
fbq(‘track’, ‘ViewContent’);
</script>And this page on the orange button “book nu” and “vis interesse”, I wish to put this code, because will be a lead from there…:
<script>
fbq(‘track’, ‘Lead’);
</script>How is that done in the enfold theme?
July 11, 2018 at 1:57 am #983938Hey AuroraArcus,
Thank you for using Enfold.
Use the code or text block element of the advance layout builder. You can also use hooks or filters to add the script.
// https://codex.wordpress.org/Plugin_API/Action_Reference/wp_head
// https://codex.wordpress.org/Plugin_API/Filter_Reference/the_contentBest regards,
IsmaelJuly 11, 2018 at 8:53 am #984077Hi Ismael,
thanks, I created the code block on the landing page.
I tried putting the:
<script>
fbq(‘track’, ‘Lead’);
</script>into the “book nu!” button’s custom css class, but it’s not working.
Can you describe, how I track the button? (I don’t understand the hooks and filters concept!)
Best regards,
AuroraJuly 11, 2018 at 11:40 am #984141Hi Aurora,
This is not the correct code, you should check FB documentation for the correct function to attach the tracking event to a button and then we can help you implement it.
Best regards,
VictoriaJuly 11, 2018 at 12:52 pm #984203Hi Victoria
Ok thanks – I will look into it. Fyi, the button is not a sale, but opens up for the possibility to mail me. I don’t know if that changes anything?
Where should I put the code, when it’s a button?
July 12, 2018 at 2:35 am #984418Hi,
You can still add the code or script in the code block element. The following is an example of the tracking code. You need to replace the id selector with your own. Example.
<!-- Add Pixel Events to the button's click handler --> <script type="text/javascript"> var button = document.getElementById('YOUR OWN CUSTOM ID SELECTOR'); button.addEventListener( 'click', function() { fbq('track', 'AddToCart', { content_name: 'Really Fast Running Shoes', content_category: 'Apparel & Accessories > Shoes', content_ids: ['1234'], content_type: 'product', value: 4.99, currency: 'USD' }); }, false ); </script>
// https://developers.facebook.com/docs/facebook-pixel/api-reference
Best regards,
IsmaelJuly 12, 2018 at 11:11 pm #984911Hi Ismael,
Thanks for the info.
Using the info from you and this link:
https://developers.facebook.com/docs/facebook-pixel/events-advanced-use-cases/v3.0
I put in this into a code block in the top of the page.<!– Somewhere there is a button that performs Add to Cart –>
<button id=”addToCartButton”>Add To Cart</button><!– Add Pixel Events to the button’s click handler –>
<script type=”text/javascript”>
var button = document.getElementById(‘Book Nu!’);
button.addEventListener(
‘click’,
function() {
fbq(‘track’, ‘AddToCart’, {
content_name: ‘Book Nu!’,
value: 25,
currency: ‘DKK’
});
},
false
);
</script>Unfortunately, “Facebook pixel helper” keeps on giving me an error. Could you look through the second block of code I have put in there and tell me howcome it’s not working? (i’m trying to put a pixel trigger on the button “Book Nu!”.
Hope you can help me out, because I’ve been stuck with this for the past 2 days…
July 12, 2018 at 11:19 pm #984913Facebook also writes the following when it comes to the view a content event:
“Paste the view content event code
Place the event code on your content or detail page page.
Add the event code just below the </head> tag. This allows the event code to load along with the pixel code when the page loads.
<!– End Facebook Pixel Code –>
</head>
<body>
<script>insert_event_code_here;<script>”Where is the “content or detail page page”?. Is it the header.php for the theme?
July 16, 2018 at 2:20 am #985800 -
AuthorPosts
- You must be logged in to reply to this topic.