Morfistan Butik Tesettür Elbise Tunik Ferace
Yukarı

  WhatsApp ile sipariş verin

Özel ürünler

  WhatsApp ile sipariş verin

var GA_Enhanced_Ecommerce = true; var GTAG_TRACKING_ID = 'UA-119411574-1'; var GTAG_ADWORDS_ID = ''; var GTAG_ADWORDS_LABEL = ''; /*PAGETYPE SABİT*/ var PAGE_TYPE = PAGETYPE; if (typeof gtag == 'undefined') { var s = document.createElement('script'); s.setAttribute('src', 'https://www.googletagmanager.com/gtag/js?id=' + GTAG_TRACKING_ID); s.setAttribute('async', true); document.body.appendChild(s); window.dataLayer = window.dataLayer || []; /* Global configs */ function gtag() { dataLayer.push(arguments); } gtag('js', new Date()); gtag('config', GTAG_TRACKING_ID, { 'send_page_view': false }); gtag('config', GTAG_ADWORDS_ID); } switch (PAGE_TYPE) { case 'index': gtag('event', 'page_view', { ecomm_pagetype: 'home' }); break; case 'product': gtag_detail(); break; case 'category': gtag_list(); break; case 'basket': gtag_cart(); break; case 'payment': gtag_payment(); break; case 'address': gtag_address(); break; case 'approve': gtag_purchase(); break; case 'search': gtag('event', 'page_view', { ecomm_pagetype: 'searchresults' }); break; default: gtag('event', 'page_view', { ecomm_pagetype: 'other' }); break; } function gtag_detail() { try { var productData = _PRODUCT; gtag('event', 'view_item', { 'items': [{ 'id': ret(productData.sku), 'name': ret(productData.title), 'brand': ret(productData.brand), 'category': ret(productData.category), 'list_position': 1 }] }); gtag('event', 'page_view', { ecomm_pagetype: 'product', ecomm_totalvalue: ret(productData.price), ecomm_prodid: ret(productData.sku), ecomm_category: ret(productData.category) }); console.log('gtag -> view_item'); } catch (err) { console.log(err); } } function gtag_list() { try { var category = CATEGORY_TEMP; var products = CATEGORY_PRODUCTS; var productData = []; for (var i in products) { if (i > 20) { break; } productData.push({ 'id': ret(products[i].sku), 'name': ret(products[i].title), 'brand': ret(products[i].brand), 'category': ret(products[i].category), 'list': ret(category.title), 'list_position': (i + 1) }); } gtag('event', 'view_item_list', { 'items': productData }); gtag('event', 'page_view', { ecomm_pagetype: 'category', ecomm_category: ret(category.title) }); console.log('gtag -> view_item_list'); } catch (err) { console.log(err); } } function gtag_getCartItems() { var cart = { products: [], total: 0 }; try { var r = _BASKET; var items = r.items; var total = (r.price.sub_total + r.price.vat_total).toFixed(2); cart.total = total; for (var i in items) { var _price = items[i].price > 0 ? items[i].discounted_price : items[i].price; cart.products.push({ 'id': ret(items[i].sku), 'name': ret(items[i].title), 'brand': ret(items[i].brand), 'category': ret(items[i].category), 'price': ret(_price) }); } } catch (err) { console.log(err); } return cart; } function gtag_cart() { try { var cart = gtag_getCartItems(); if (cart.products.length <= 0) { return false; } gtag('event', 'begin_checkout', { 'items': cart.products }); gtag('event', 'page_view', { ecomm_pagetype: 'cart', ecomm_totalvalue: cart.total || 0, ecomm_prodid: get_cartPID() }); console.log('gtag -> begin_checkout'); } catch (err) { console.log(err); } } function gtag_address() { try { var cart = gtag_getCartItems(); if (cart.products.length <= 0) { return false; } gtag('config', GTAG_TRACKING_ID, { 'send_page_view': false, 'page_path': '/shopping/order/order' }); gtag('event', 'checkout_progress', { 'items': cart.products }); gtag('event', 'page_view', { ecomm_pagetype: 'other', ecomm_totalvalue: cart.total || 0, ecomm_prodid: get_cartPID() }); console.log('gtag -> address'); } catch (err) { console.log(err); } } function get_cartPID() { var cart = gtag_getCartItems(); if (cart.products.length <= 0) { return false; } var pid = []; for (var i in cart.items) { if (ret(cart.items[i].sku) != '') pid.push(ret(cart.items[i].sku)); } return pid; } function gtag_payment() { try { var cart = gtag_getCartItems(); if (cart.products.length <= 0) { return false; } gtag('config', GTAG_TRACKING_ID, { 'send_page_view': false, 'page_path': '/shopping/order/order/payment/' }); gtag('event', 'checkout_progress', { 'items': cart.products }); gtag('event', 'page_view', { ecomm_pagetype: 'other', ecomm_totalvalue: cart.total || 0, ecomm_prodid: get_cartPID() }); console.log('gtag -> payment'); } catch (err) { console.log(err); } } function gtag_purchase() { try { var products = []; var currency = _ORDER.price.currency; var items = _ORDER.items; var _total = _ORDER.price.totalPrice; var _total_vat = _ORDER.price.vatTotal; var _service_fee = _ORDER.price.paymentPrice; var _cargo_fee = _ORDER.price.cargoPrice; var _order_number = _ORDER.order_number; for (var i in items) { products.push({ 'id': ret(items[i].sku), 'name': ret(items[i].title), 'brand': ret(items[i].brand), 'category': ret(items[i].category), 'quantity': ret(items[i].count), 'price': ret(items[i].price.amountWithTax) }); } /* Track AdWords conversions */ gtag('event', 'conversion', { 'send_to': GTAG_ADWORDS_ID + '/' + GTAG_ADWORDS_LABEL, 'value': _total, 'currency': currency === 'TL' ? 'TRY' : currency, 'transaction_id': _order_number }); console.log('gtag -> conversion'); /* Track analytics transaction */ gtag('config', GTAG_TRACKING_ID, { 'send_page_view': false, 'page_path': '/shopping/order/order/complete' }); gtag('event', 'purchase', { 'transaction_id': _order_number, 'value': _total, 'currency': currency === 'TL' ? 'TRY' : currency, 'tax': _total_vat, 'shipping': _cargo_fee, 'items': products }); gtag('event', 'page_view', { ecomm_pagetype: 'purchase', ecomm_totalvalue: _total || 0, ecomm_prodid: get_cartPID() }); console.log('gtag -> purchase'); } catch (err) { console.log(err); } } $(document).on('click', '#fastBuyBtn, .addbasket', function () { try { var _counter = $('[name="count"]'); if (_counter) { _counter = _counter.val(); } else { _counter = 1; } var _price = _PRODUCT.discounted_price > 0 ? _PRODUCT.discounted_price : _PRODUCT.price; gtag('event', 'add_to_cart', { 'items': [{ 'id': ret(_PRODUCT.sku), 'name': ret(_PRODUCT.title), 'brand': ret(_PRODUCT.brand), 'quantity': _counter, 'price': _price }] }); console.log('gtag -> add to cart'); } catch (err) { console.log(err); } });