Integracja edrone z platformą Shoptet wymaga wdrożenia feedu produktowego. Przygotuj go i przekaż swojemu opiekunowi onboardingowemu do wgrania do naszego systemu.
Zaloguj się do panelu administracyjnego i z menu po lewej stronie wybierz "Wygląd i treść", a następnie przejdź do sekcji "Edytor".
Otwórz zakładkę edytora HTML i wklej poniższe kody odpowiednio do sekcji Header, Footer i Order.
Jeśli nie widzisz zakładki edytora HTML, skontaktuj się z pomocą techniczną platformy Shoptet.
Header
<script type="text/javascript">
(function (srcjs) {
window._edrone = window._edrone || {};
_edrone.app_id = 'YOUR_APP_ID';
_edrone.version = '1.0.0';
_edrone.platform_version = '1.0.0';
_edrone.platform = 'shoptet';
var doc = document.createElement('script');
doc.type = 'text/javascript';
doc.async = true;
doc.src = ('https:' == document.location.protocol ? 'https:' : 'http:') + srcjs;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(doc, s);
})("//d3bo67muzbfgtl.cloudfront.net/edrone_2_0.js");
</script>
Powyższy skrypt wymaga uzupełnienia o app_id, który można znaleźć w sekcji Integracje w ustawieniach edrone
Footer
<script type="text/javascript">
const edroneCategories = (string, spliter) => {
if (string.indexOf(spliter) > -1) {
let temp = string.split(spliter);
return temp.join("~");
} else {
return string;
}
};
if (dataLayer[0].shoptet.pageType == "productDetail") {
var data = {
product_id: dataLayer[0].shoptet.product.id,
product_titles: dataLayer[0].shoptet.product.name,
product_image: document.querySelector('meta[itemprop="image"]').content,
product_url: document.querySelector('.p-detail meta[itemprop="url"]')
.content,
product_category: edroneCategories(
dataLayer[0].shoptet.product.currentCategory,
"|"
),
};
window._edrone = window._edrone || {};
_edrone.product_ids = data.product_id;
_edrone.product_titles = data.product_titles; // use url_encode
_edrone.product_images = data.product_image;
_edrone.product_urls = data.product_url;
_edrone.product_category_names = data.product_category;
_edrone.action_type = "product_view";
let addToCartButton = document.querySelector(
'form[action="/action/Cart/addCartItem/"] button'
);
if (addToCartButton) {
addToCartButton.addEventListener("click", () => {
_edrone.action_type = "add_to_cart";
_edrone.init();
});
}
}
if (dataLayer[0].shoptet.pageType == "customerDetails") {
const submitOrderButton = document.querySelector("#submit-order");
if (submitOrderButton) {
submitOrderButton.addEventListener("click", () => {
const name = document.querySelector("#billFullName").value.split(" ");
const customerData = {
first_name: name[0],
last_name: name[1],
email: document.querySelector("#email").value
};
localStorage.setItem("customerData", JSON.stringify(customerData));
});
}
}
</script>
Order
<script type="text/javascript">
const getOrderData = () => {
const items = dataLayer[0].shoptet.order.content;
let itemsName = "";
let itemsID = "";
let itemsCounts = "";
items.forEach((element, index) => {
if (index == items.length - 1) {
itemsName += element.name;
itemsID += element.id;
itemsCounts += element.quantity.toString();
} else {
itemsName += element.name + "|";
itemsID += element.id
itemsCounts += element.quantity.toString() + "|";
}
});
return {
names: itemsName,
ids: itemsID,
counts: itemsCounts,
order_value: dataLayer[0].shoptet.order.total,
order_id: dataLayer[0].shoptet.order.orderNo,
country: dataLayer[0].shoptet.order.country,
city: dataLayer[0].shoptet.order.city,
currency: dataLayer[0].shoptet.order.currencyCode
};
};
const orderData = getOrderData();
const customerData = JSON.parse(localStorage.getItem('customerData'));
window._edrone = window._edrone || {};
_edrone.action_type = "order";
_edrone.email = customerData.email;
_edrone.first_name = customerData.first_name;
_edrone.last_name = customerData.last_name;
_edrone.product_ids = orderData.ids
_edrone.product_titles = orderData.names
_edrone.product_counts = orderData.counts
_edrone.order_id = orderData.order_id
_edrone.country = orderData.country;
_edrone.city = orderData.city
_edrone.base_currency = orderData.currency;
_edrone.order_currency = orderData.currency;
_edrone.base_payment_value = orderData.order_value
_edrone.order_payment_value = orderData.order_value
localStorage.removeItem('customerData');
</script>
Po wklejeniu powyższych kodów zapisz zmiany.