Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
608 Weergaven

i connect one product with facebook platform 

facebook show below error

Avatar
Annuleer
Beste antwoord

1. Asegurate de tener tu pixel insertado. Sin integraciones, solo pixel.
2. Asegurate que el pixel sea la unica fuente de datos del catálogo.
3. Añade este código en el código en el head:


<t t-set="retailer_id" t-value="str(product.id)"/>

<t t-set="amount"       t-value="'%.2f' % (product.price or product.website_price or product.list_price)"/>

<t t-set="currency"     t-value="(pricelist and pricelist.currency_id and pricelist.currency_id.name) or 'MXN'"/>

<t t-set="availability" t-value="'in stock' if (product.sudo().qty_available or 0.0) > 0 else 'out of stock'"/>

<t t-set="img_url"      t-value="request.httprequest.url_root + 'web/image/product.template/%s/image_1024' % product.id"/>


4. Añade este código en la pagina de producto "website_sale.product" justo después de la linea que dice "<section id="product_detail"...:
<!-- Microdato de ID para Meta / Google -->

<span itemprop="productID" style="display:none"> <t t-esc="product.default_code or product.id"/>

</span>

<meta property="product:retailer_item_id" t-att-content="product.default_code or product.id"/>

<t t-set="retailer_id" t-value="str(product.id)"/>  <!-- o SKU: product.default_code or str(product.id) -->

<t t-set="availability" t-value="'in stock' if (product.sudo().qty_available or 0.0) &gt; 0 else 'out of stock'"/>

<t t-set="amount" t-value="float(product.list_price or 0.0)"/>

<t t-set="currency" t-value="(pricelist and pricelist.currency_id and pricelist.currency_id.name) or 'MXN'"/>

<t t-set="desc_txt" t-value="product.description_sale or product.name"/>


<div id="fbProductMeta" t-att-data-id="retailer_id" t-att-data-availability="availability" t-att-data-amount="'%.2f' % amount" t-att-data-currency="currency" t-att-data-name="product.name" t-att-data-desc="desc_txt" style="display:none"/>


<script>

document.addEventListener('DOMContentLoaded', function () {

try {

if (typeof window.fbq !== 'function') return;

var d = document.getElementById('fbProductMeta').dataset;

function cleanId(s){ return String(s||'').replace(/[\[\]"']/g,'').trim(); }

var cid = cleanId(d.id);

 var amt = parseFloat(d.amount||'0')||0;

 var cur = (d.currency||'MXN').toUpperCase();

var nm  = (d.name||'').replace(/["']/g,' ');

var ds  = (d.desc||'').replace(/["']/g,' ');

  var p   = {};

p.content_ids  = [cid];

p.content_type = 'product';

p.content_name = nm;

p.value        = amt;

p.currency     = cur;

p.availability = d.availability||'';

p.description  = ds;

p.price        = amt.toFixed(2)+' '+cur;

p.url          = location.href;

var img = document.querySelector('#product_details img[src*="/web/image/"]');

if (img) p.image_url = img.src;

fbq('track', 'ViewContent', p);

} catch(e) { if (console) console.warn(e); }

 ​});

</script>


Quiza haya mejoras que se puedan hacer en este código pero a mi me funcionó.








Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
feb. 25
566
2
aug. 25
1838
2
jul. 25
3470
1
jul. 25
712
0
mei 25
1187