I've added the code below in view.phtml to track ViewContent.
<script> fbq('init', 'xxxxxxxxxxx'); fbq('track', 'ViewContent', { content_ids: '<?php echo $this->htmlEscape($_product->getData('sku'));?>', content_type: 'product', value: <?php echo $_product->getPrice(); ?>, currency: '<?php echo Mage::app()->getStore()->getCurrentCurrencyCode(); ?>' }); </script>
In Chrome's pixel helper, the following custom parameters are sent for ViewContent;
content_type: product
content_ids: CT2985 (this is the product sku)
value: 29.95
currency: USD
As you can see, these parameters looks like it's being recognized, however in the facebook diagnostics, it's telling me that the "Required parameter content_type and content_ids are missing from ViewContent events". Any help is greatly appreciated as usual.
I wonder what would happen if you submit an array containing your SKU, instead of just a single SKU as a string. The FB docs say you can submit a string or an array of strings, but I'm curious if this could be the source of your problem.
Tip: HTML escaping something doesn't make it safe to put in JSON. JSON encoding it does. For this reason, you should replace
$this->htmlEscape
with
Mage::helper('core')->jsonEncode
Or, even cleaner:
Mage::helper('core')->jsonEncode(array( 'content_ids' => array($_product->getData('sku')), 'content_type' => 'product', 'value' => $_product->getPrice(), 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode() ));
You could also check into setting this up with Google Tag Manager so that you don't have to modify any templates files and break upgradability. I created a free module which populates the dataLayer array with similar data: https://github.com/bubbleupdev/BubbleUp_Gtmdatalayer/
Hey @b7itzz
The issues showed in your Facebook diagnostics may be not about product pages but other site pages like categories, search results, etc. So the product pages have the parameters and others are missing them as they are not relevant (I saw a similar problem with AdWords custom options).
You can still check how your FB pixel tags are firing under Assets > Pixels and compare the data with GA or other tracking system you have. This will help you figure out if the pixel works correctly.
Hey, sorry I've been away. Let me check on this. Thanks for the help!
Thanks for sharing such a nice info, i am also adding facebook pixel just a few days before with the help you facebook pixel helper. Here i found a detail guide on pixel helper might be helpful to other https://www.withintheflow.com/facebook-pixel-helper/
Make your life simpler with all new Trackify X - it will help you integrate your facebook pixel with Shopify store seamlessly. No coding, no technical stuff.
Apart from that, Trackify X Shopify facebook pixel reporting with the help of the new pixel engine is able to generate more reliable reports within the dashboard. You can also adjust the percentage value of purchase events with just a simple click!