/* required tmp.js */ var googleCart = { nextStep: function(step, callback) { if ($("#googleCart").length > 0) { var json = $("#googleCart").data('json'); dataLayer.push({ 'event': 'checkout', 'ecommerce': { 'checkout': { 'actionField': {'step': step, 'option': json.transportName}, 'products': json.positions, } }, 'eventCallback': function() { //console.log(dataLayer); callback; } }); } else { callback; } }, } $(document).ready(function() { if (typeof dataLayer !== "undefined" && typeof dataLayer.push !== "undefined") { $("body").on("click", "a[data-event-action]", function() { dataLayer.push({ 'event': 'GAevent', 'eventCategory': $(this).attr('data-event-name'), 'eventAction': $(this).attr('data-event-action'), }); }); $("body").on("click", ".ua_add_to_cart", function() { dataLayer.push({ 'event': 'DoKoszyka', 'ecommerce': { 'currencyCode': 'PLN', 'add': { 'products': [{ 'name': $(this).attr("data-product-name"), 'id': $(this).attr("data-product-index"), 'price': $(this).attr("data-product-price"), 'brand': $(this).attr("data-product-brand"), 'category': $(this).attr("data-product-category"), 'quantity': $(this).attr("data-product-quantity") }] } } }); }); $('body').on('click', '#add_pg_to_cart', function(e) { var pg = $('input[type="radio"][name="pakiet"]:checked'); dataLayer.push({ event: 'DoKoszyka', ecommerce: { 'currencyCode': 'PLN', 'add': { 'products': [{ 'name': $(".ua_add_to_cart").attr("data-product-name"), 'id': $(".ua_add_to_cart").attr("data-product-index"), 'price': $(".ua_add_to_cart").attr("data-product-price"), 'brand': $(".ua_add_to_cart").attr("data-product-brand"), 'category': $(".ua_add_to_cart").attr("data-product-category"), 'quantity': $(".ua_add_to_cart").attr("data-product-quantity") }, { 'name': pg.attr("data-product-name"), 'id': 'Ubezpieczenie', 'price': pg.attr("data-product-price"), 'brand': 'Ubezpieczenie', 'category': 'Ubezpieczenie', 'quantity': 1 }] } }, eventCallback: function() { $('form#addInsuranceForm').submit(); } }); return false; }); /* product list click */ $("body").on("click", ".list_product .list_prd_title a,.list_product .read_more", function() { var list = "Search Results"; if ($(this).closest('.list_product').find('.ua_add_to_cart').is("[data-promotion-list-name]")) { list = $(this).closest('.list_product').find('.ua_add_to_cart').attr("data-promotion-list-name"); } /* get index of position */ var per_page = 20; if ($("#per_page")) { per_page = $("#per_page").val(); } var page = 1; if ($(".jumpToPage").length > 0) { page = $(".jumpToPage").attr('data-cpage'); } var position = $(".list_product").index($(this).closest('.list_product')) + 1 + ((page - 1) * per_page); var href = $(this).attr('href'); dataLayer.push({ 'event': 'productClick', 'ecommerce': { 'click': { 'actionField': {'list': list}, 'products': [{ 'name': $(this).closest('.list_product').find('.ua_add_to_cart').