Copy/Paste this at the end of you head tag
<script>
window.leftySettings = {
debug: true, // must be false in production
};
(function (t, e) {
t._lefty = t._lefty || [];
t.lefty = function () {
t._lefty.push(arguments);
};
var c = e.createElement("script");
c.setAttribute(
"src",
"https://cdn.jsdelivr.net/gh/leftyio/lefty-affiliation@latest/dist/index.min.js"
);
c.setAttribute("async", "");
c.onload = function () {
lefty("init", window.leftySettings);
};
e.head.appendChild(c);
})(window, document);
</script>Starts building the order
var product = Lefty.createProduct(PRODUCT_ID, name);
var productItem = Lefty.createProductItem(
ITEM_ID,
product,
20, // total amount
2 // quantitiy
);
var order = Lefty.createOrder(
ORDER_ID,
[
productItem,
// Add more product items
],
"USD"
);
lefty("conversion", "<PIXEL_ID>", order);Alternative to xhr conversion, using pixel-based tracking.
var product = Lefty.createProduct(PRODUCT_ID, name);
var productItem = Lefty.createProductItem(
ITEM_ID,
product,
20, // total amount
2 // quantity
);
var order = Lefty.createOrder(
ORDER_ID,
[
productItem,
// Add more product items
],
"USD"
);
lefty("pixel", "<PIXEL_ID>", order);https://shopify.dev/docs/api/web-pixels-api
For Shopify Web Pixel API, installation is different. Initialize your pixel with the following script.
window._lefty = window._lefty || [];
function lefty() {
_lefty.push(arguments);
}
var script = document.createElement("script");
script.setAttribute(
"src",
"https://cdn.jsdelivr.net/gh/leftyio/lefty-affiliation@latest/dist/index.min.js"
);
script.setAttribute("async", "");
document.head.appendChild(script);Then subscribe to shopify events you want and trigger lefty conversion.
analytics.subscribe("checkout_completed", (event) => {
let checkout = event.data.checkout;
// build lefty order using shopify checkout data
lefty("conversion", "<PIXEL_ID>", order);
});