I'm trying to start implementing some dynamic marketing on Facebook. To do this, I need to use the Facebook Pixels to track users behaviors.

<script>
fbq('track', 'ViewContent', {
content_ids: ['1234'],
content_type: 'product'
value: 0.50,
currency: 'USD'
});
</script>

The issue I have is having this code update with each different product. I was able to update the code (below) using EE tags to get the data I need, but to do so, I have to place the Facebook pixel code inside the EE {exp: loop. When doing this, Facebook doesn't recognize the pixel code. If I leave it outside of the {exp: loop, the EE tags don't work.

Updated code:

<script>
    fbq('track', 'ViewContent', {
        content_ids: ['{product_item_id}'],
        content_type: 'product'
        value: '{price}',
        currency: 'USD'
    });
</script>

Has anyone else had this issue with ExpressionEngine and Facebook Pixels? I'm running EE 2.8.1, Expresso Store 2.5.

try adding a protect_javascript variable in in config.php:

$config['protect_javascript'] = 'n';
  • How will this help send the data to Facebook though? – db123 Nov 9 '16 at 14:21
  • It tells EE to ignore script tags and parse as js. – stuartmcd69 Nov 10 '16 at 2:18

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.