Facebook pixel code with twig is giving error

1

I'm doing a pixel code in twig on Xtech, but the code gives an error. (It takes all the information right, but it does not work correctly.)

I use the Google Chrome plugin called Facebook Pixel Helper from Facebook.

I wanted you to help me figure out what's going on to make these mistakes and how to make them up.

Is there something wrong with javascript? Is something missing?

<script>!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,document,'script','//connect.facebook.net/en_US/fbevents.js');//InsertYourFacebookPixelIDbelow.fbq('init','1690502541167948');fbq('track','PageView');{%ifproduct%}fbq('track','ViewContent',{content_name:'{{product.name|e('html')}}',content_category:'{{(product.current_category?product.current_category['name']:get_product_category(product.id))|e('html')}}',content_ids:['{{product.id}}'],content_type:'product',value:{{product.saleprice>0?product.saleprice:product.price}},currency:'{{shop_config('currency')}}'});{%elseifpayment_methods%}fbq('track','AddToCart',{content_name:'ShoppingCart',content_category:'teste',content_ids:[{%forcartkey,productincart('contents')%}'{{product.id}}'{{loop.last?'':','}}{%endfor%}],content_type:'product',value:{{cart('total')|number_format(2,".", "")
    }
  },
  currency: '{{ shop_config('
  currency ') }}'
}); { % elseif 'order_placed' in current_url() %
}
fbq('track', 'Purchase', {
  content_ids: [{ %
      for product in order.contents %
    }
    '{{ product.id }}' {
      {
        loop.last ? '' : ', '
      }
    } { % endfor %
    }
  ],
  content_type: 'product',
  value: {
    {
      order.total | number_format(2, ".", "")
    }
  },
  currency: '{{ shop_config('
  currency ') }}'
}); { % endif %
}

Thank you

    
asked by anonymous 09.12.2015 / 17:42

0 answers