I'm trying to use Facebook Pixel to track ViewContent event on products. Facebook says that it's required to pass content_ids or contents and content_type.
I guess content_type should always be 'product' and I can write that manually but how can I pass product id dynamically to 'content_ids' on each product page?
fbq('trackSingle', 'myfacebookpixelid', 'ViewContent', {
content_ids: ''
content_type: 'product'
})
I have a product.js page that is used as the product page and I have the product id as this.state.product._id
How should I initialize FB Pixel on this page and how can I pass the product ID into content_ids?
Any guidance is welcome, thanks!
I managed to solve this myself. I just had to pass the product id to the Facebook Pixel component on the Product page. Then I passed it to the ViewContent event in the content_ids.