0

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.

1 Answer 1

1

try adding a protect_javascript variable in in config.php:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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