Marketplaces i zarządzanie integracjami Integracja z Synerise Estimated reading: 5 minutes 5 views Integracja z Synerise pozwala na scentralizowanie danych o zachowaniach klientów i automatyzację działań marketingowych. Za jej pomocą możesz śledzić zdarzenia, np. wyświetlenia produktów, dodania do koszyka, zakupy) przy użyciu kodów śledzących i API. Sprawdź, jak skonfigurować integrację oraz poznaj jej zakres, w sklepie na platformie AtomStore. Konfiguracja ustawień modułu 1. Przejdź do Ustawienia Konfiguracja sklepu Wygląd sklepu Kody marketingowe JS Synerise . 2. Skonfiguruj ustawienia: Tracker Key – podaj unikalny identyfikator pobierany z platformy Synerise (jest niezbędny do zainicjowania kodu śledzącego); API Key – podaj klucz API utworzony wcześniej w platformie Synerise; Adres trackera – podaj jeżeli nie chcesz korzystać z domyślnego; Identyfikator indeksu wyszukiwarki – podaj jeżeli chcesz aby wyszukiwarka produktów działała w oparciu o Synerise. 3. Zapisz dane. Zakres integracji – jakie zdarzenia są obsługiwane? Integracja JavaScript (Tracking Code) Kod na stronie: 1. CartStatus: SR.event.trackCustomEvent("cart.status", { products : sr_products, totalAmount : {Wartość koszyka}, totalQuantity: {Suma sztuk w koszyku} }, "CartStatus" ); 2. addToCart – dodanie produktu do koszyka: syneriseLayer.push({ 'event' : 'addToCart', 'ecommerce': { 'currencyCode': 'PLN', 'add' : { 'products': dataLayerProducts } } }); 3. removeFromCart – usunięcie produkt z koszuka: syneriseLayer.push({ 'event' : 'removeFromCart', 'ecommerce': { 'currencyCode': 'PLN', 'remove' : { 'products': removed_products } } }); 4. Lista produktów (‘products’) zawiera: { 'name' : {Nazwa produktu}, 'price' : {Cena produktu}, 'id' : {ID produktu}, 'brand' : {Producent}, 'category': {Kategoria}, 'variant' : {Wariant} } Integracja API 1. Złożenie zamówienia: Zdarzenie ‘Order’: <?php $order['Order']['created'] = getOrderField($order['Order']['id'], 'created'); $order_products = []; foreach ($order['OrderProduct'] as $order_product): $order_products[] = [ '$sku' => getProductCode($order_product['product_id']), '$quantity' => $order_product['quantity'], 'product:price:currency' => $order['Order']['currency_code'], '$finalUnitPrice' => number_format($order_product['product_price'] * (1 + $order_product['tax_value'] / 100), 2, '.', ''), 'product:price:amount' => number_format($order_product['default_price'] * (1 + $order_product['tax_value'] / 100), 2, '.', ''), '$name' => $order_product['product_name'], '$currency' => $order['Order']['currency_code'], ]; endforeach; $data = [ 'time' => date('c'), 'label' => getOrderFullId($order['Order']['id'], true), 'action' => 'order', 'client' => [ 'uuid' => $_COOKIE['_snrs_uuid'] ], 'params' => [ '$revenue' => getOrderPrice($order['Order']['id']), 'products' => $order_products, '$source' => 'WEB_DESKTOP', '$totalAmount' => getProductsPrice($order['Order']['id']), '$orderId' => getOrderFullId($order['Order']['id'], true), '$paymentType' => $order['Order']['payment_method'], '$currency' => $order['Order']['currency_code'], '$paymentType' => $order['Order']['payment_method'], 'snr-original-time' => date('r', strtotime($order['Order']['created'])), 'eventCreateTime' => date('r', strtotime($order['Order']['created'])) ] ]; getController('Synerise')->_callApi('events/custom', $data); ?> Zdarzenie ‘product.order’ – dla każdego produktu z zamówienia: <?php foreach ($order['OrderProduct'] as $order_product): $product_data = [ 'time' => date('c'), 'label' => getOrderFullId($order['Order']['id'], true), 'action' => 'product.order', 'client' => [ 'uuid' => $_COOKIE['_snrs_uuid'] ], 'params' => [ '$name' => $order_product['product_name'], '$quantity' => $order_product['quantity'], 'ProductType' => getCategoryName(getProductMainCategoryId($order_product['product_id'])), '$sku' => getProductCode($order_product['product_id']), '$orderId' => getOrderFullId($order['Order']['id'], true), '$finalUnitPrice' => number_format($order_product['product_price'] * (1 + $order_product['tax_value'] / 100), 2, '.', ''), '$currency' => $order['Order']['currency_code'], 'AssortmentName' => 'Half price', 'snr-original-time' => date('r', strtotime($order['Order']['created'])), '$orderId' => getOrderFullId($order['Order']['id'], true), 'eventCreateTime' => date('r', strtotime($order['Order']['created'])) ] ]; getController('Synerise')->_callApi('events/custom', $product_data); endforeach; ?> 2. Dodatkowe zdarzenia: Po zalogowaniu na konto – wysłanie informacji o kliencie: <?php function _sendUserToSynerise(){ if (!empty($_COOKIE['_snrs_p'])){ $identity_hash = null; foreach (explode('&', $_COOKIE['_snrs_p']) as $line){ $line = explode(':', $line); if ($line[0] == 'identityHash'){ $identity_hash = $line[1]; break; } } if (!$identity_hash){ if ($email = getUserField(getLoggedUserId(), 'email')){ App::import('Vendor', 'Uuid', ['file' => 'uuid'.DS.'vendor'.DS.'autoload.php']); $uuid = (string) Uuid::uuid5(Uuid::NAMESPACE_URL, $_SERVER['SERVER_NAME'].$email); $data = [ [ 'email' => $email, 'uuid' => $uuid ], [ 'email' => $email, 'uuid' => $_COOKIE['_snrs_uuid'] ] ]; $this->_callApi('clients/batch', $data); setcookie('_snrs_reset_uuid', $uuid); } }else{ if ($email = getUserField(getLoggedUserId(), 'email')){ $email_hash = $this->_getHashCode($email); if ($email_hash != $identity_hash){ App::import('Vendor', 'Uuid', ['file' => 'uuid'.DS.'vendor'.DS.'autoload.php']); $uuid = (string) Uuid::uuid5(Uuid::NAMESPACE_URL, $_SERVER['SERVER_NAME'].$email); $data = [ [ 'email' => $email, 'uuid' => $uuid ] ]; $this->_callApi('clients/batch', $data); setcookie('_snrs_reset_uuid', $uuid); } } } } } ?> Wysłanie zdrzenie form.submit: <?php if (isset($_COOKIE['_snrs_uuid'])){ $data = [ 'time' => date('c'), 'label' => 'Login form', 'action' => 'form.submit', 'client' => [ 'uuid' => $_COOKIE['_snrs_uuid'] ], 'params' => [ 'formType' => 'clientLastLogin' ] ]; getController('Synerise')->_callApi('events/custom', $data); } ?> Dodanie produktu do schowka – product.addToFavorite: <?php $data = [ 'time' => date('c'), 'action' => 'product.addToFavorite', 'label' => 'Add Product To Favorites', 'client' => [ 'uuid' => $_COOKIE['_snrs_uuid'] ], 'params' => [ 'eventCreateTime' => date('c'), 'productId' => $product_id, 'origin' => isMobile() ? 'Mobile' : 'Desktop', 'source' => isMobile() ? 'WEB_MOBILE' : 'WEB_DESKTOP', 'sku' => getProductCode($product_id), 'productName' => getProductName($product_id), 'finalUnitPrice' => str_replace(',', '.', showPrice($product_price['price'], false)), 'currency' => getCurrentCurrency('code') ] ]; getController('Synerise')->_callApi('events/custom', $data); ?> Usunięcie produktu ze schowka – product.removeFromFavorites: <?php $data = [ 'time' => date('c'), 'action' => 'product.removeFromFavorites', 'label' => 'Remove Product From Favorites', 'client' => [ 'uuid' => $_COOKIE['_snrs_uuid'] ], 'params' => [ 'eventCreateTime' => date('c'), 'productId' => $product_id, 'origin' => isMobile() ? 'Mobile' : 'Desktop', 'source' => isMobile() ? 'WEB_MOBILE' : 'WEB_DESKTOP', 'sku' => getProductCode($product_id), 'productName' => getProductName($product_id), 'finalUnitPrice' => str_replace(',', '.', showPrice($product_price['price'], false)), 'currency' => getCurrentCurrency('code') ] ]; getController('Synerise')->_callApi('events/custom', $data); ?> Korzystanie z wyszukiwarki produktów po API Synerise Tagged:Integracja z SyneriseIntegracjeSynerise