cancel
Showing results for 
Search instead for 
Did you mean: 

Facebook Pixel Required Parameters

Facebook Pixel Required Parameters

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. 

5 REPLIES 5

Re: Facebook Pixel Required Parameters

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/

Re: Facebook Pixel Required Parameters

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.

Was my answer helpful? You can accept it as a solution.
230+ professional extensions for M1 & M2 with free lifetime updates!

Re: Facebook Pixel Required Parameters

Hey, sorry I've been away. Let me check on this. Thanks for the help!

Re: Facebook Pixel Required Parameters

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/

Re: Facebook Pixel Required Parameters

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!