RedditPP Mascot

RedditPP

r/woocommerce • … • u/roron123

Woocommerce retargeting on Facebook problem...

I have a client running Woocommerce on a WordPress site, and I want to be able to dynamically retarget products on Facebook. Each product page has a SKU on the DOM, so I am currently passing that as my Content\_ID in my [ViewContent event](https://imgur.com/Q8EG26G), as seen below. The {{Product View - Product ID}} variable is that SKU taken directly from the DOM:

<script> fbq('track', 'ViewContent', { content\\\_name: {{Product View - Product Name}}, content\\\_category: 'Product Category', content\\\_ids: {{Product View - Product ID}}, content\\\_type: 'product', value: {{Product View - Product Price}}, currency: 'USD' }); </script>

The SKU is passed in the product feed from Woocommerce to Facebook in a <g:mpn> tag in the product feed. But Facebook tries to match the Content\_ID from my ViewContent events with the <g:id> tag on the product feed. The <g:id> tag has a totally different value, and I can't figure out a way to pass that in my ViewContent parameters. In the product feed, it has <g:id>woocommerce\_gpf\_55171</g:id>. I can see where the 55171 is coming from in the Products section of the Wordpress dashboard. It is the number assigned to a variation of the product, seen [HERE](https://imgur.com/R3wLpuV).

So basically, I need to either find a way to get that woocommerce\_gpf\_55171 from somewhere so I can put it in a variable to pass as a parameter in my ViewContent event, or I need to somehow get Facebook to match Content\_IDs to the <g:mpn> instead of <g:id>. Anyone know how to do either of those?

Before you say "just use a plugin", this is a touchy client and I don't have access to their webmaster, and we're not allowed to start adding plugins without permission. I'm hoping there is a way to do this directly in GTM/FB. Thanks!

— 0