Google Remarketing Tracking Script

<script>
var pid = '';
var ptype = 'other';
var tot = 0.0;

if(window.location.pathname == '/'){
ptype = 'home';
}
else if(jquery('div').hasClass('productView-img-container')){
pid = jquery('[name="product_id"]').val();
ptype = 'product';
tot = jquery('.productView-price .price.price--withTax').text().replace(/[^0-9.]/g,'');
}
else if(window.location.pathname.match('/cart.php')){
pid = [];
jquery('.cart-item-block.cart-item-figure').each(function(){
pid.push(jquery(this).find('img').attr('data-src').split('/products/')[1].split('/')[0])
})
tot = jquery('.cart-total-grandTotal').text().replace(/[^0-9.]/g,'');
ptype = 'cart';
}
else if(jquery('div').hasClass('category-description')){
ptype = 'category';
}
else{
ptype = 'other';
}
var google_tag_params = {
ecomm_prodid: pid,
ecomm_pagetype: ptype,
ecomm_totalvalue: parseFloat(tot)
};
gtag('event', 'page_view', {'send_to': 'AW-747581619',
'ecomm_prodid':window.google_tag_params.ecomm_prodid,
'ecomm_pagetype': window.google_tag_params.ecomm_pagetype,
'ecomm_totalvalue':window.google_tag_params.ecomm_totalvalue
});

</script>

 

Want a Fast Server Like Mine?

GET VULTR!