Last active
August 17, 2017 09:53
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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