Skip to content

Instantly share code, notes, and snippets.

@swym-public
Last active August 17, 2017 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swym-public/74704778d822f2e138b7a00c32c53660 to your computer and use it in GitHub Desktop.
Save swym-public/74704778d822f2e138b7a00c32c53660 to your computer and use it in GitHub Desktop.
FB Pixel tracking sample code for AddtoWishlist actions on your e-commerce site via the Swym Wishlist Plus app
(function(){
var startListening = function(){
window._swat.evtLayer.addEventListener(SwymTracker.JSEvents.addedToWishlist, function(e){
var evtData = e.detail.d;
/* Sample data format that gets passed
evtData format -
{
et: 4 for wishlist,
dt: // product title
du: // product full url
epi: // variant id
empi: // product id
pr: // price
iu: // image url
};
*/
/* Calling the FB Pixel tracking function w/ the right args */
window.fbq("track", "AddToWishlist", {
content_ids: [evtData.empi],
content_type: "product_group",
content_name: evtData.dt,
content_category: evtData.ct,
currency: SwymUtils.getOGData()["og:price:currency"],
value: evtData.pr
});
});
};
if(!window._swat){
if(!window.SwymCallbacks){
window.SwymCallbacks = [];
}
window.SwymCallbacks.push(startListening);
}else{
startListening();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment