A recurring question in the Google Tag Manager communities (e.g. product forums) is how to use an Enhanced Ecommerce dataLayer object with the Facebook pixel code? It’s a common question since running a Facebook conversion pixel on a site that also collects data from the store into Google Analytics’ Enhanced Ecommerce reports is probably a very typical scenario. Side note: Since Google+ is about to go the way of the dodo, I’ve created an archive of the entire community which you can browse and make text searches against.
A while ago, I published a #GTMTips article, where I showed how you can add HTML elements to the page programmatically using Google Tag Manager. This is relevant because GTM’s validators prevent you from adding custom parameters to HTML elements that are injected directly via the Custom HTML tag. To circumvent this validation, you need to create the element programmatically, before appending it to the document. A while ago, Matteo Gamba asked me a question related to the Facebook Customer Chat Plugin.
Facebook’s pixel has an attribute named content_ids (required for Dynamic Ads), which requires an Array of content IDs as its value. It’s very possible you’re running this pixel on a site which already has Enhanced Ecommerce for Universal Analytics implemented, and now you want to use the same Enhanced Ecommerce data that your developers have already made available in this Facebook pixel. Or perhaps you want to concatenate a list of strings, such as article tags (['culture', 'politics']), and send it as a comma-separated string to Google Analytics ('culture,politics').