first commit

This commit is contained in:
2024-11-05 12:22:50 +01:00
commit e5682a3912
19641 changed files with 2948548 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2012-2022 Patryk Marek PrestaDev.pl
*
* Patryk Marek PrestaDev.pl - PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module © All rights reserved.
*
* DISCLAIMER
*
* Do not edit, modify or copy this file.
* If you wish to customize it, contact us at info@prestadev.pl.
*
* @author Patryk Marek <info@prestadev.pl>
* @copyright 2012-2022 Patryk Marek @ PrestaDev.pl
* @license Do not edit, modify or copy this file, if you wish to customize it, contact us at info@prestadev.pl.
* @link http://prestadev.pl
* @package PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module
* @version 1.0.1
* @date 01-05-2021
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,832 @@
/*
* 2012-2022 Patryk Marek PrestaDev.pl
*
* Patryk Marek PrestaDev.pl - PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module © All rights reserved.
*
* DISCLAIMER
*
* Do not edit, modify or copy this file.
* If you wish to customize it, contact us at info@prestadev.pl.
*
* @author Patryk Marek <info@prestadev.pl>
* @copyright 2012-2022 Patryk Marek @ PrestaDev.pl
* @license Do not edit, modify or copy this file, if you wish to customize it, contact us at info@prestadev.pl.
* @link http://prestadev.pl
* @package PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module
* @version 1.0.2
* @date 01-05-2021
*/
$(document).ready(function() {
let pdgoogleanalytycs4pro_quantity_wanted = 1,
PdDelayFunction = (function () {
var timer = 0;
return function (callback, ms) {
clearTimeout(timer);
timer = setTimeout(callback, ms);
};
})();
// supercheckout send carrier and payment default selections events
if ($("body#module-supercheckout-supercheckout").length > 0) {
PdDelayFunction(function () {
let id_carrier = parseInt($('input.delivery_option_radio:checked').val());
if (typeof(id_carrier) !== 'undefined'){
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'addDeliveryInfo', 'id_carrier': id_carrier, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax: true},
dataType: "json",
success: function(data) {
if (data) {
$('#hook-display-before-carrier').html(data);
}
}
});
}
let payment_module = $('input[name=payment_method]:checked').data('module-name');
if (typeof(payment_module) !== 'undefined'){
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'addPaymentInfo', 'payment_module': payment_module, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax: true},
dataType: "json",
success: function(data) {
if (data) {
$('#hook-display-before-carrier').html(data);
}
}
});
}
}, 1500);
}
// supercheckout
$("body#module-supercheckout-supercheckout").on("click", "input.delivery_option_radio:checked", function() {
let id_carrier = parseInt(this.value);
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'addDeliveryInfo', 'id_carrier': id_carrier, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax: true},
dataType: "json",
success: function(data) {
if (data) {
$('#hook-display-before-carrier').html(data);
}
}
});
});
// supercheckout
$("body#module-supercheckout-supercheckout").on("click", "input[name=payment_method]:checked", function() {
let payment_module = $(this).data('module-name');
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'addPaymentInfo', 'payment_module': payment_module, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax: true},
dataType: "json",
success: function(data) {
if (data) {
$('#hook-display-before-carrier').html(data);
}
}
});
});
// thecheckout send carrier and payment default selections events
if ($("body#module-thecheckout-order").length > 0) {
PdDelayFunction(function () {
let id_carrier = parseInt($('input[type=radio][name^=delivery_option]:checked').val());
if (typeof(id_carrier) !== 'undefined'){
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'addDeliveryInfo', 'id_carrier': id_carrier, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax: true},
dataType: "json",
success: function(data) {
if (data) {
$('#hook-display-before-carrier').html(data);
}
}
});
}
let payment_module = $('input[name=payment-option]:checked').data('module-name');
if (typeof(payment_module) !== 'undefined'){
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'addPaymentInfo', 'payment_module': payment_module, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax: true},
dataType: "json",
success: function(data) {
if (data) {
$('#hook-display-before-carrier').html(data);
}
}
});
}
}, 1000);
}
$("body#module-thecheckout-order").on("click", "input[type=radio][name^=delivery_option]:checked", function() {
let id_carrier = parseInt(this.value);
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'addDeliveryInfo', 'id_carrier': id_carrier, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax: true},
dataType: "json",
success: function(data) {
if (data) {
$('#hook-display-before-carrier').html(data);
}
}
});
});
$("body#module-thecheckout-order").on("click", "input[name=payment-option]:checked", function() {
let payment_module = $(this).data('module-name');
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'addPaymentInfo', 'payment_module': payment_module, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax: true},
dataType: "json",
success: function(data) {
if (data) {
$('#hook-display-before-carrier').html(data);
}
}
});
});
$("body#checkout").on("click", '.delivery-options input[type="radio"]:checked', function() {
let id_carrier = parseInt(this.value);
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'addDeliveryInfo', 'id_carrier': id_carrier, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax: true},
dataType: "json",
success: function(data) {
if (data) {
$('#hook-display-before-carrier').html(data);
}
}
});
});
$("body#checkout").on("click", 'input[name="payment-option"]:checked', function() {
let payment_module = $(this).data('module-name');
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'addPaymentInfo', 'payment_module': payment_module, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax: true},
dataType: "json",
success: function(data) {
if (data) {
$('#hook-display-before-carrier').html(data);
}
}
});
});
// opc steasycheckout
$("body.module-steasycheckout-default").on("click", 'input[type=radio][name^=delivery_option]:checked', function() {
let id_carrier = parseInt(this.value);
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'addDeliveryInfo', 'id_carrier': id_carrier, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax: true},
dataType: "json",
success: function(data) {
if (data) {
$('#hook-display-before-carrier').html(data);
}
}
});
});
// opc steasycheckout
$("body.module-steasycheckout-default").on("click", 'input[name="payment-option"]:checked', function() {
let payment_module = $(this).data('module-name');
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'addPaymentInfo', 'payment_module': payment_module, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax: true},
dataType: "json",
success: function(data) {
if (data) {
$('#hook-display-before-carrier').html(data);
}
}
});
});
if (typeof(prestashop) !== 'undefined') {
//prestashop.on('changedCheckoutStep', function(params) {
// if (typeof(params.event.currentTarget.id) !== 'undefined') {
// let step = params.event.currentTarget.id,
// step_call_elm = params.event.target.id;
// if (step == 'checkout-payment-step' && step_call_elm != 'conditions_to_approve[terms-and-conditions]') {
// let payment_module = $('input[name="payment-option"]:checked').data('module-name');
// $.ajax({
// type: "POST",
// url: pdgoogleanalytycs4pro_ajax_link,
// data: {'action': 'addPaymentInfo', 'payment_module': payment_module, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax: true},
// dataType: "json",
// success: function(data) {
// if (data) {
// $('#hook-display-before-carrier').html(data);
// }
// }
// });
// }
// }
//});
if (pd_google_analitycs_controller != 'cart') {
prestashop.on('updateProduct', function(params) {
if (typeof(params) !== 'undefined') {
pdgoogleanalytycs4pro_quantity_wanted = $(params.event.currentTarget).val();
}
});
}
if (pd_google_analitycs_controller != 'cart') {
prestashop.on('updateCart', function(params) {
if (typeof(params) !== 'undefined' && typeof(prestashop.cart) !== 'undefined') {
let iso_code = prestashop.currency.iso_code,
product_id = params.reason.idProduct,
product_id_product_attribute = params.reason.idProductAttribute;
if (typeof(product_id) !== 'undefined' && typeof(product_id_product_attribute) !== 'undefined' && typeof(pdgoogleanalytycs4pro_quantity_wanted) !== 'undefined') {
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'updateCart', 'product_id': product_id, 'product_id_product_attribute' : product_id_product_attribute, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax : true},
dataType: "json",
success: function(data) {
console.log('Fired up event GA4: add_to_cart');
gtag('event', 'add_to_cart', {
currency: iso_code,
items: [{
item_id: data.content_ids,
item_name: data.content_name,
coupon: '',
discount: data.content_discount,
index: '1',
item_list_name: pd_google_analitycs_controller,
item_list_id: pd_google_analitycs_controller,
affiliation: data.http_referer,
item_brand: data.content_manufacturer,
item_category: data.content_category,
item_category2: (data.content_category2.length) ? data.content_category2 : '',
item_category3: (data.content_category3.length) ? data.content_category3 : '',
item_category4: (data.content_category4.length) ? data.content_category4 : '',
item_category5: (data.content_category5.length) ? data.content_category5 : '',
item_variant: data.content_variant,
price: data.content_value_old,
currency: iso_code,
quantity: pdgoogleanalytycs4pro_quantity_wanted
}],
value: data.content_value
});
}
});
}
}
});
}
// qty up > thecheckout module opc
$('body').on("click", "a.cart-line-product-quantity-up", function(e) {
let qty_input = $(this).parent().find('input.cart-line-product-quantity'),
updat_url = qty_input.attr('data-update-url'),
url_params = PdParseQuery(updat_url),
iso_code = prestashop.currency.iso_code;
if (typeof(url_params.id_product) !== 'undefined' && typeof(url_params.id_product_attribute) !== 'undefined') {
var product_id_product = url_params.id_product;
var product_id_product_attribute = url_params.id_product_attribute;
}
if (typeof(product_id_product) !== 'undefined' && typeof(product_id_product_attribute) !== 'undefined') {
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'updateCart', 'product_id': product_id_product, 'product_id_product_attribute' : product_id_product_attribute, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax : true},
dataType: "json",
success: function(data) {
console.log('Fired up event GA4: add_to_cart');
gtag('event', 'add_to_cart', {
currency: iso_code,
items: [{
item_id: data.content_ids,
item_name: data.content_name,
coupon: '',
discount: data.content_discount,
index: '1',
item_list_name: pd_google_analitycs_controller,
item_list_id: pd_google_analitycs_controller,
affiliation: data.http_referer,
item_brand: data.content_manufacturer,
item_category: data.content_category,
item_category2: (data.content_category2.length) ? data.content_category2 : '',
item_category3: (data.content_category3.length) ? data.content_category3 : '',
item_category4: (data.content_category4.length) ? data.content_category4 : '',
item_category5: (data.content_category5.length) ? data.content_category5 : '',
item_variant: data.content_variant,
price: data.content_value,
currency: iso_code,
quantity: 1
}],
value: data.content_value
});
}
});
}
});
// qty up > thecheckout module opc user entered value
$('body').on("keyup", "input.cart-line-product-quantity", function(e) {
PdDelayFunction(function () {
let qty_input = $('input.cart-line-product-quantity'),
qty_input_val = parseInt($('input.cart-line-product-quantity').val()),
updat_url = qty_input.attr('data-update-url'),
url_params = PdParseQuery(updat_url),
iso_code = prestashop.currency.iso_code;
if (typeof(url_params.id_product) !== 'undefined' && typeof(url_params.id_product_attribute) !== 'undefined') {
var product_id_product = url_params.id_product;
var product_id_product_attribute = url_params.id_product_attribute;
}
if (typeof(product_id_product) !== 'undefined' && typeof(product_id_product_attribute) !== 'undefined' && qty_input_val > 0) {
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'updateCart', 'product_id': product_id_product, 'product_id_product_attribute' : product_id_product_attribute, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax : true},
dataType: "json",
success: function(data) {
console.log('Fired up event GA4: add_to_cart');
gtag('event', 'add_to_cart', {
currency: iso_code,
items: [{
item_id: data.content_ids,
item_name: data.content_name,
coupon: '',
discount: data.content_discount,
index: '1',
item_list_name: pd_google_analitycs_controller,
item_list_id: pd_google_analitycs_controller,
affiliation: data.http_referer,
item_brand: data.content_manufacturer,
item_category: data.content_category,
item_category2: (data.content_category2.length) ? data.content_category2 : '',
item_category3: (data.content_category3.length) ? data.content_category3 : '',
item_category4: (data.content_category4.length) ? data.content_category4 : '',
item_category5: (data.content_category5.length) ? data.content_category5 : '',
item_variant: data.content_variant,
price: data.content_value,
currency: iso_code,
quantity: qty_input_val
}],
value: data.content_value
});
}
});
}
}, 800);
});
// down qty > thecheckout module opc
$('body').on("click", "a.cart-line-product-quantity-down", function(e) {
let qty_input = $(this).parent().find('input.cart-line-product-quantity'),
updat_url = qty_input.attr('data-update-url'),
url_params = PdParseQuery(updat_url),
iso_code = prestashop.currency.iso_code;
if (typeof(url_params.id_product) !== 'undefined' && typeof(url_params.id_product_attribute) !== 'undefined') {
var product_id_product = url_params.id_product;
var product_id_product_attribute = url_params.id_product_attribute;
}
if (typeof(product_id_product) !== 'undefined' && typeof(product_id_product_attribute) !== 'undefined') {
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'updateCart', 'product_id': product_id_product, 'product_id_product_attribute' : product_id_product_attribute, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax : true},
dataType: "json",
success: function(data) {
console.log('Fired up event GA4: remove_from_cart');
gtag('event', 'remove_from_cart', {
currency: iso_code,
items: [{
item_id: data.content_ids,
item_name: data.content_name,
coupon: '',
discount: data.content_discount,
index: '1',
item_list_name: pd_google_analitycs_controller,
item_list_id: pd_google_analitycs_controller,
affiliation: data.http_referer,
item_brand: data.content_manufacturer,
item_category: data.content_category,
item_category2: (data.content_category2.length) ? data.content_category2 : '',
item_category3: (data.content_category3.length) ? data.content_category3 : '',
item_category4: (data.content_category4.length) ? data.content_category4 : '',
item_category5: (data.content_category5.length) ? data.content_category5 : '',
item_variant: data.content_variant,
price: data.content_value_old,
currency: iso_code,
quantity: 1
}],
value: data.content_value
});
}
});
}
});
// qty up > stadard theme ps 17
$('body').on("click", "button.bootstrap-touchspin-up", function(e) {
let qty_input = $(this).parent().parent().find('input.js-cart-line-product-quantity'),
updat_url = qty_input.attr('data-update-url'),
url_params = PdParseQuery(updat_url),
iso_code = prestashop.currency.iso_code;
if (typeof(url_params.id_product) !== 'undefined' && typeof(url_params.id_product_attribute) !== 'undefined') {
var product_id_product = url_params.id_product;
var product_id_product_attribute = url_params.id_product_attribute;
}
if (typeof(product_id_product) !== 'undefined' && typeof(product_id_product_attribute) !== 'undefined') {
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'updateCart', 'product_id': product_id_product, 'product_id_product_attribute' : product_id_product_attribute, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax : true},
dataType: "json",
success: function(data) {
console.log('Fired up event GA4: add_to_cart');
gtag('event', 'add_to_cart', {
currency: iso_code,
items: [{
item_id: data.content_ids,
item_name: data.content_name,
coupon: '',
discount: data.content_discount,
index: '1',
item_list_name: pd_google_analitycs_controller,
item_list_id: pd_google_analitycs_controller,
affiliation: data.http_referer,
item_brand: data.content_manufacturer,
item_category: data.content_category,
item_category2: (data.content_category2.length) ? data.content_category2 : '',
item_category3: (data.content_category3.length) ? data.content_category3 : '',
item_category4: (data.content_category4.length) ? data.content_category4 : '',
item_category5: (data.content_category5.length) ? data.content_category5 : '',
item_variant: data.content_variant,
price: data.content_value_old,
currency: iso_code,
quantity: 1
}],
value: data.content_value
});
}
});
}
});
// qty down > stadard theme ps 17
$('body').on("click", "button.bootstrap-touchspin-down", function(e) {
let qty_input = $(this).parent().parent().find('input.js-cart-line-product-quantity'),
updat_url = qty_input.attr('data-update-url'),
url_params = PdParseQuery(updat_url),
iso_code = prestashop.currency.iso_code;
if (typeof(url_params.id_product) !== 'undefined' && typeof(url_params.id_product_attribute) !== 'undefined') {
var product_id_product = url_params.id_product;
var product_id_product_attribute = url_params.id_product_attribute;
}
if (typeof(product_id_product) !== 'undefined' && typeof(product_id_product_attribute) !== 'undefined') {
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'productClick', 'product_id': product_id_product, 'product_id_product_attribute' : product_id_product_attribute, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax : true},
dataType: "json",
success: function(data) {
console.log('Fired up event GA4: remove_from_cart');
gtag('event', 'remove_from_cart', {
currency: iso_code,
items: [{
item_id: data.content_ids,
item_name: data.content_name,
coupon: '',
discount: data.content_discount,
index: '1',
item_list_name: pd_google_analitycs_controller,
item_list_id: pd_google_analitycs_controller,
affiliation: data.http_referer,
item_brand: data.content_manufacturer,
item_category: data.content_category,
item_category2: (data.content_category2.length) ? data.content_category2 : '',
item_category3: (data.content_category3.length) ? data.content_category3 : '',
item_category4: (data.content_category4.length) ? data.content_category4 : '',
item_category5: (data.content_category5.length) ? data.content_category5 : '',
item_variant: data.content_variant,
price: data.content_value_old,
currency: iso_code,
quantity: 1
}],
value: data.content_value
});
}
});
}
});
$('body').on("click", ".js-product-miniature a.product_img_link", function(e) {
let product_container = $(this).parents('article'),
product_url = $(this).attr('href').trim(),
product_id = product_container.attr('data-id-product'),
product_id_product_attribute = product_container.attr('data-id-product-attribute');
iso_code = prestashop.currency.iso_code;
if (typeof(product_id) !== 'undefined' && typeof(product_id_product_attribute) !== 'undefined' && typeof(product_url) !== 'undefined') {
e.preventDefault();
setTimeout(function () {
document.location = product_url;
}, 700);
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'productClick', 'product_id': product_id, 'product_id_product_attribute' : product_id_product_attribute, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax : true},
dataType: "json",
success: function(data) {
console.log('Fired up event GA4: select_item');
gtag('event', 'select_item', {
currency: iso_code,
items: [{
item_id: data.content_ids,
item_name: data.content_name,
coupon: '',
discount: data.content_discount,
index: '1',
item_list_name: pd_google_analitycs_controller,
item_list_id: pd_google_analitycs_controller,
affiliation: data.http_referer,
item_brand: data.content_manufacturer,
item_category: data.content_category,
item_category2: (data.content_category2.length) ? data.content_category2 : '',
item_category3: (data.content_category3.length) ? data.content_category3 : '',
item_category4: (data.content_category4.length) ? data.content_category4 : '',
item_category5: (data.content_category5.length) ? data.content_category5 : '',
item_variant: data.content_variant,
price: data.content_value_old,
currency: iso_code,
quantity: 1
}],
item_list_name: pd_google_analitycs_controller,
item_list_id: pd_google_analitycs_controller
});
}
});
}
});
// standard theme ps 1.7 select item
$('body').on("click", ".js-product-miniature a.thumbnail", function(e) {
let product_container = $(this).parents('article'),
product_url = $(this).attr('href').trim(),
product_id = product_container.attr('data-id-product'),
product_id_product_attribute = product_container.attr('data-id-product-attribute');
iso_code = prestashop.currency.iso_code;
if (typeof(product_id) !== 'undefined' && typeof(product_id_product_attribute) !== 'undefined' && typeof(product_url) !== 'undefined') {
e.preventDefault();
setTimeout(function () {
document.location = product_url;
}, 700);
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'productClick', 'product_id': product_id, 'product_id_product_attribute' : product_id_product_attribute, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax : true},
dataType: "json",
success: function(data) {
console.log('Fired up event GA4: select_item');
gtag('event', 'select_item', {
currency: iso_code,
items: [{
item_id: data.content_ids,
item_name: data.content_name,
coupon: '',
discount: data.content_discount,
index: '1',
item_list_name: pd_google_analitycs_controller,
item_list_id: pd_google_analitycs_controller,
affiliation: data.http_referer,
item_brand: data.content_manufacturer,
item_category: data.content_category,
item_category2: (data.content_category2.length) ? data.content_category2 : '',
item_category3: (data.content_category3.length) ? data.content_category3 : '',
item_category4: (data.content_category4.length) ? data.content_category4 : '',
item_category5: (data.content_category5.length) ? data.content_category5 : '',
item_variant: data.content_variant,
price: data.content_value_old,
currency: iso_code,
quantity: 1
}],
item_list_name: pd_google_analitycs_controller,
item_list_id: pd_google_analitycs_controller
});
}
});
}
});
// Transformer theme add to cart butons on product lists
$('body').on("click", ".ajax_add_to_cart_button", function(e) {
let article = $(this).parents('article.js-product-miniature'),
product_qty = parseInt(article.find('input[name=pro_quantity]').val()),
product_id = parseInt(article.attr('data-id-product')),
product_id_product_attribute = parseInt(article.attr('data-id-product-attribute')),
iso_code = prestashop.currency.iso_code;
if (typeof(product_id) !== 'undefined' && typeof(product_id_product_attribute) !== 'undefined') {
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'updateCart', 'product_id': product_id, 'product_id_product_attribute' : product_id_product_attribute, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax : true},
dataType: "json",
success: function(data) {
console.log('Fired up event GA4: add_to_cart');
gtag('event', 'add_to_cart', {
currency: iso_code,
items: [{
item_id: data.content_ids,
item_name: data.content_name,
coupon: '',
discount: data.content_discount,
index: '1',
item_list_name: pd_google_analitycs_controller,
item_list_id: pd_google_analitycs_controller,
affiliation: data.http_referer,
item_brand: data.content_manufacturer,
item_category: data.content_category,
item_category2: (data.content_category2.length) ? data.content_category2 : '',
item_category3: (data.content_category3.length) ? data.content_category3 : '',
item_category4: (data.content_category4.length) ? data.content_category4 : '',
item_category5: (data.content_category5.length) ? data.content_category5 : '',
item_variant: data.content_variant,
price: data.content_value_old,
currency: iso_code,
quantity: product_qty ? product_qty : pdgoogleanalytycs4pro_quantity_wanted
}],
value: data.content_value
});
}
});
}
});
prestashop.on('updateProduct', function(params) {
if (typeof(params) !== 'undefined' && params.eventType == 'updatedProductCombination') {
let iso_code = prestashop.currency.iso_code,
product_id = parseInt(document.getElementsByName('id_product')[0].value),
groups = [],
select_groups = document.getElementsByClassName('form-control-select'),
input_color_group = document.getElementsByClassName('input-color'),
input_radio_group = document.querySelector('.input-radio:checked');
if (typeof(select_groups) != 'undefined' && select_groups != null) {
for (select_count = 0; select_count < select_groups.length; select_count++) {
groups.push(select_groups[select_count].value);
}
}
if (typeof(input_color_group) != 'undefined' && input_color_group != null) {
for (color_count = 0; color_count < input_color_group.length; color_count++) {
if (input_color_group[color_count].checked) {
groups.push(input_color_group[color_count].value);
}
}
}
if (typeof(input_radio_group) != 'undefined' && input_radio_group != null) {
for (radio_count = 0; radio_count < input_radio_group.length; radio_count++) {
if (input_radio_group[radio_count].checked) {
groups.push(input_radio_group[radio_count].value);
}
}
}
if (typeof groups !== 'undefined' && groups.length > 0 && typeof product_id !== 'undefined') {
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'updateProduct', 'product_id': product_id, 'attributes_groups': groups,'secure_key': pdgoogleanalytycs4pro_secure_key, ajax : true},
dataType: "json",
success: function(data) {
console.log('Fired up event GA4: view_item on combination change');
PdSetEventFireUpDelay(250);
gtag('event', 'view_item', {
items: [{
item_id: data.content_ids,
item_name: data.content_name,
coupon: "",
discount: data.content_discount,
affiliation: data.http_referer,
item_list_name: pd_google_analitycs_controller,
item_list_id: pd_google_analitycs_controller,
item_brand: data.content_manufacturer,
item_category: data.content_category,
item_category2: (data.content_category2.length) ? data.content_category2 : '',
item_category3: (data.content_category3.length) ? data.content_category3 : '',
item_category4: (data.content_category4.length) ? data.content_category4 : '',
item_category5: (data.content_category5.length) ? data.content_category5 : '',
item_variant: data.content_variant,
price: data.content_value_old,
currency: iso_code,
quantity: 1
}],
value: data.content_value
});
}
});
}
}
});
}
function PdSetEventFireUpDelay(ms) {
var cur_d = new Date();
var cur_ticks = cur_d.getTime();
var ms_passed = 0;
while(ms_passed < ms) {
var d = new Date();
var ticks = d.getTime();
ms_passed = ticks - cur_ticks;
}
}
function PdParseQuery(str) {
if(typeof str != "string" || str.length == 0) return {};
var s = str.split("&");
var s_length = s.length;
var bit, query = {}, first, second;
for(var i = 0; i < s_length; i++) {
bit = s[i].split("=");
first = decodeURIComponent(bit[0]);
if(first.length == 0) continue;
second = decodeURIComponent(bit[1]);
if(typeof query[first] == "undefined") query[first] = second;
else if(query[first] instanceof Array) query[first].push(second);
else query[first] = [query[first], second];
}
return query;
}
});

View File

@@ -0,0 +1,51 @@
{*
* 2012-2022 Patryk Marek PrestaDev.pl
*
* Patryk Marek PrestaDev.pl - PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module © All rights reserved.
*
* DISCLAIMER
*
* Do not edit, modify or copy this file.
* If you wish to customize it, contact us at info@prestadev.pl.
*
* @author Patryk Marek <info@prestadev.pl>
* @copyright 2012-2022 Patryk Marek @ PrestaDev.pl
* @license Do not edit, modify or copy this file, if you wish to customize it, contact us at info@prestadev.pl.
* @link http://prestadev.pl
* @package PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module
* @version 1.0.2
* @date 01-05-2021
*}
<!-- PD Google Analytycs 4 Pro - EVENT > add_shipping_info -->
<script type="text/javascript">
console.log('Fired up event GA4: add_shipping_info');
gtag('event', 'add_shipping_info', {
coupon: '{$content_coupon|escape:'htmlall':'UTF-8'}',
currency: '{$currency|escape:'htmlall':'UTF-8'}',
items: [
{foreach from=$content_products item=product name=products}
{
item_id: '{$product.content_ids|escape:'htmlall':'UTF-8'}',
item_name: '{$product.name|escape:'htmlall':'UTF-8'}',
coupon: '{$product.content_coupon|escape:'htmlall':'UTF-8'}',
discount: {$product.discount|escape:'htmlall':'UTF-8'},
affiliation: '{$http_referer|escape:'htmlall':'UTF-8'}',
item_brand: '{$product.manufacturer_name|escape:'htmlall':'UTF-8'}',
item_category: '{$product.content_category|escape:'htmlall':'UTF-8'}',
{if !empty($product.content_category2)}item_category2: '{$product.content_category2|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category3)}item_category3: '{$product.content_category3|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category4)}item_category4: '{$product.content_category4|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category5)}item_category5: '{$product.content_category5|escape:'htmlall':'UTF-8'}',{/if}
item_variant: '{if isset($product.variant)}{$product.variant|escape:'htmlall':'UTF-8'}{/if}',
price: {$product.price_old|floatval},
currency: '{$currency|escape:'htmlall':'UTF-8'}',
quantity: '{$product.cart_quantity|escape:'htmlall':'UTF-8'}'
},
{/foreach}
],
shipping_tier: '{$carrier_name|escape:'htmlall':'UTF-8'}',
value: {$content_value|escape:'htmlall':'UTF-8'}
});
</script>
<!-- PD Google Analytycs 4 Pro - EVENT > add_shipping_info -->

View File

@@ -0,0 +1,52 @@
{*
* 2012-2022 Patryk Marek PrestaDev.pl
*
* Patryk Marek PrestaDev.pl - PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module © All rights reserved.
*
* DISCLAIMER
*
* Do not edit, modify or copy this file.
* If you wish to customize it, contact us at info@prestadev.pl.
*
* @author Patryk Marek <info@prestadev.pl>
* @copyright 2012-2022 Patryk Marek @ PrestaDev.pl
* @license Do not edit, modify or copy this file, if you wish to customize it, contact us at info@prestadev.pl.
* @link http://prestadev.pl
* @package PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module
* @version 1.0.2
* @date 01-05-2021
*}
<!-- PD Google Analytycs 4 Pro - EVENT > add_payment_info -->
<script type="text/javascript">
console.log('Fired up event GA4: add_payment_info');
gtag('event', 'add_payment_info', {
coupon: '{$content_coupon|escape:'htmlall':'UTF-8'}',
currency: '{$currency|escape:'htmlall':'UTF-8'}',
items: [
{foreach from=$content_products item=product name=products}
{
item_id: '{$product.content_ids|escape:'htmlall':'UTF-8'}',
item_name: '{$product.name|escape:'htmlall':'UTF-8'}',
coupon: '{$product.content_coupon|escape:'htmlall':'UTF-8'}',
discount: {$product.discount|escape:'htmlall':'UTF-8'},
affiliation: '{$http_referer|escape:'htmlall':'UTF-8'}',
item_brand: '{$product.manufacturer_name|escape:'htmlall':'UTF-8'}',
item_category: '{$product.content_category|escape:'htmlall':'UTF-8'}',
{if !empty($product.content_category2)}item_category2: '{$product.content_category2|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category3)}item_category3: '{$product.content_category3|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category4)}item_category4: '{$product.content_category4|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category5)}item_category5: '{$product.content_category5|escape:'htmlall':'UTF-8'}',{/if}
item_variant: '{if isset($product.variant)}{$product.variant|escape:'htmlall':'UTF-8'}{/if}',
price: {$product.price_old|escape:'htmlall':'UTF-8'},
currency: '{$currency|escape:'htmlall':'UTF-8'}',
quantity: '{$product.cart_quantity|escape:'htmlall':'UTF-8'}'
},
{/foreach}
],
payment_type: '{$payment_name|escape:'htmlall':'UTF-8'}',
value: {$content_value|escape:'htmlall':'UTF-8'}
});
</script>
<!-- PD Google Analytycs 4 Pro - EVENT > add_payment_info -->

View File

@@ -0,0 +1,34 @@
{*
* 2012-2022 Patryk Marek PrestaDev.pl
*
* Patryk Marek PrestaDev.pl - PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module © All rights reserved.
*
* DISCLAIMER
*
* Do not edit, modify or copy this file.
* If you wish to customize it, contact us at info@prestadev.pl.
*
* @author Patryk Marek <info@prestadev.pl>
* @copyright 2012-2022 Patryk Marek @ PrestaDev.pl
* @license Do not edit, modify or copy this file, if you wish to customize it, contact us at info@prestadev.pl.
* @link http://prestadev.pl
* @package PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module
* @version 1.0.2
* @date 01-05-2021
*}
<!-- PD Google Analytycs 4 Pro - EVENT > refund -->
<script type="text/javascript">
console.log('Fired up event GA4: refund');
gtag('event', 'refund', {
currency: '{$currency|escape:'htmlall':'UTF-8'}',
transaction_id: '{$transaction_id|escape:'htmlall':'UTF-8'}',
value: {$value|escape:'htmlall':'UTF-8'},
affiliation: '{$affiliation|escape:'htmlall':'UTF-8'}',
coupon: '{$coupon|escape:'htmlall':'UTF-8'}',
shipping: {$shipping|escape:'htmlall':'UTF-8'},
tax: {$tax|escape:'htmlall':'UTF-8'}
});
</script>
<!-- PD Google Analytycs 4 Pro - EVENT > refund -->

View File

@@ -0,0 +1,40 @@
{*
* 2012-2022 Patryk Marek PrestaDev.pl
*
* Patryk Marek PrestaDev.pl - PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module © All rights reserved.
*
* DISCLAIMER
*
* Do not edit, modify or copy this file.
* If you wish to customize it, contact us at info@prestadev.pl.
*
* @author Patryk Marek <info@prestadev.pl>
* @copyright 2012-2022 Patryk Marek @ PrestaDev.pl
* @license Do not edit, modify or copy this file, if you wish to customize it, contact us at info@prestadev.pl.
* @link http://prestadev.pl
* @package PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module
* @version 1.0.1
* @date 01-05-2021
*}
{if isset($pd_google_analytics_id)}
<!-- START > PD Google Analytycs 4.0 1.6.x and 1.7.x Module -->
<script async data-keepinline="true" src="https://www.googletagmanager.com/gtag/js?id={$pd_google_analytics_id|escape:'htmlall':'UTF-8'}"></script>
{literal}
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{/literal}{$pd_google_analytics_id|escape:'htmlall':'UTF-8'}{literal}', {'send_page_view': {/literal}{$pd_google_analytics_spv|escape:'htmlall':'UTF-8'}{literal}});
{/literal}{if isset($pd_google_analytics_id2) && !empty($pd_google_analytics_id2)}{literal}gtag('config', '{/literal}{$pd_google_analytics_id2|escape:'htmlall':'UTF-8'}{literal}', {'send_page_view': {/literal}{$pd_google_analytics_spv|escape:'htmlall':'UTF-8'}{literal}});
{/literal}{/if}{literal}gtag('set', {currency: '{/literal}{$pd_google_analytics_currency|escape:'htmlall':'UTF-8'}{literal}'});
gtag('set', {country: '{/literal}{$pd_google_analytics_country|escape:'htmlall':'UTF-8'}{literal}'});
{/literal}{if isset($pd_google_analytics_id_aw) && !empty($pd_google_analytics_id_aw)}{literal}gtag('config', '{/literal}{$pd_google_analytics_id_aw|escape:'htmlall':'UTF-8'}{literal}');
{/literal}{/if}{literal}
</script>
{/literal}
<!-- END > PD Google Analytycs 4.0 1.6.x and 1.7.x Module -->
{/if}

View File

@@ -0,0 +1,28 @@
{*
* 2012-2022 Patryk Marek PrestaDev.pl
*
* Patryk Marek PrestaDev.pl - PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module © All rights reserved.
*
* DISCLAIMER
*
* Do not edit, modify or copy this file.
* If you wish to customize it, contact us at info@prestadev.pl.
*
* @author Patryk Marek <info@prestadev.pl>
* @copyright 2012-2022 Patryk Marek @ PrestaDev.pl
* @license Do not edit, modify or copy this file, if you wish to customize it, contact us at info@prestadev.pl.
* @link http://prestadev.pl
* @package PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module
* @version 1.0.2
* @date 01-05-2021
*}
<script type="text/javascript">
{literal}
gtag('event', 'login', {
method: 'PrestaShop'
});
{/literal}
</script>

View File

@@ -0,0 +1,372 @@
{*
* 2012-2022 Patryk Marek PrestaDev.pl
*
* Patryk Marek PrestaDev.pl - PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module © All rights reserved.
*
* DISCLAIMER
*
* Do not edit, modify or copy this file.
* If you wish to customize it, contact us at info@prestadev.pl.
*
* @author Patryk Marek <info@prestadev.pl>
* @copyright 2012-2022 Patryk Marek @ PrestaDev.pl
* @license Do not edit, modify or copy this file, if you wish to customize it, contact us at info@prestadev.pl.
* @link http://prestadev.pl
* @package PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module
* @version 1.0.2
* @date 01-05-2021
*}
{if $tagType != 'none'}
<!-- PD Google Analytycs 4 Pro - EVENTS CODE FOOTER -->
<script type="text/javascript" >
{if ($tagType === 'product')}
console.log('Fired up event GA4: view_item > Product page');
gtag('event', 'view_item', {
items: [{
item_id: '{$content_ids|escape:'htmlall':'UTF-8'}',
item_name: '{$content_name|escape:'htmlall':'UTF-8'}',
coupon: '{$content_coupon|escape:'htmlall':'UTF-8'}',
affiliation: '{$http_referer|escape:'htmlall':'UTF-8'}',
discount: {$content_discount|escape:'htmlall':'UTF-8'},
item_brand: '{$content_manufacturer|escape:'htmlall':'UTF-8'}',
item_category: '{$content_category|escape:'htmlall':'UTF-8'}',
item_list_name: '{$item_list_name|escape:'htmlall':'UTF-8'}',
item_list_id: '{$item_list_id|escape:'htmlall':'UTF-8'}',
{if !empty($content_category2)}item_category2: '{$content_category2|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($content_category3)}item_category3: '{$content_category3|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($content_category4)}item_category4: '{$content_category3|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($content_category5)}item_category5: '{$content_category3|escape:'htmlall':'UTF-8'}',{/if}
item_variant: '{$content_variant|escape:'htmlall':'UTF-8'}',
item_list_name: "Product page",
item_list_id: '{$item_list_name|escape:'htmlall':'UTF-8'}',
list_position: 1,
price: {$content_value_old|escape:'htmlall':'UTF-8'},
currency: '{$currency|escape:'htmlall':'UTF-8'}',
quantity: 1,
}],
value: {$content_value|escape:'htmlall':'UTF-8'}
});
{else if ($tagType === 'cart')}
console.log('Fired up event GA4: view_cart');
gtag('event', 'view_cart', {
currency: '{$currency|escape:'htmlall':'UTF-8'}',
items: [
{foreach from=$content_products item=product name=products}
{
item_id: '{$product.content_ids|escape:'htmlall':'UTF-8'}',
item_name: '{$product.name|escape:'htmlall':'UTF-8'}',
coupon: '{$product.content_coupon|escape:'htmlall':'UTF-8'}',
discount: {$product.discount|escape:'htmlall':'UTF-8'},
index: {$smarty.foreach.products.index},
item_list_name: 'Cart products',
item_list_id: 1,
affiliation: '{$http_referer|escape:'htmlall':'UTF-8'}',
item_brand: '{$product.manufacturer_name|escape:'htmlall':'UTF-8'}',
item_category: '{$product.content_category|escape:'htmlall':'UTF-8'}',
{if !empty($product.content_category2)}item_category2: '{$product.content_category2|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category3)}item_category3: '{$product.content_category3|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category4)}item_category4: '{$product.content_category4|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category5)}item_category5: '{$product.content_category5|escape:'htmlall':'UTF-8'}',{/if}
item_variant: '{if isset($product.variant)}{$product.variant}{/if}',
price: {$product.price|escape:'htmlall':'UTF-8'},
currency: '{$currency|escape:'htmlall':'UTF-8'}',
quantity: '{$product.cart_quantity|escape:'htmlall':'UTF-8'}'
},
{/foreach}
],
value: {$content_value|escape:'htmlall':'UTF-8'}
});
console.log('Fired up event GA4: begin_checkout');
gtag('event', 'begin_checkout', {
coupon: '{$content_coupon|escape:'htmlall':'UTF-8'}',
currency: '{$currency|escape:'htmlall':'UTF-8'}',
items: [
{foreach from=$content_products item=product name=products}
{
item_id: '{$product.content_ids|escape:'htmlall':'UTF-8'}',
item_name: '{$product.name|escape:'htmlall':'UTF-8'}',
coupon: '{$product.content_coupon|escape:'htmlall':'UTF-8'}',
discount: {$product.discount|escape:'htmlall':'UTF-8'},
index: {$smarty.foreach.products.index},
item_list_name: 'Cart products',
item_list_id: 1,
affiliation: '{$http_referer|escape:'htmlall':'UTF-8'}',
item_brand: '{$product.manufacturer_name|escape:'htmlall':'UTF-8'}',
item_category: '{$product.content_category|escape:'htmlall':'UTF-8'}',
{if !empty($product.content_category2)}item_category2: '{$product.content_category2|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category3)}item_category3: '{$product.content_category3|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category4)}item_category4: '{$product.content_category4|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category5)}item_category5: '{$product.content_category5|escape:'htmlall':'UTF-8'}',{/if}
item_variant: '{if isset($product.variant)}{$product.variant}{/if}',
price: {$product.price|escape:'htmlall':'UTF-8'},
currency: '{$currency|escape:'htmlall':'UTF-8'}',
quantity: '{$product.cart_quantity|escape:'htmlall':'UTF-8'}'
},
{/foreach}
],
value: {$content_value|escape:'htmlall':'UTF-8'}
});
{else if ($tagType === 'order' || $tagType === 'order-opc')}
console.log('Fired up event GA4: begin_checkout');
gtag('event', 'begin_checkout', {
coupon: '{$content_coupon|escape:'htmlall':'UTF-8'}',
currency: '{$currency|escape:'htmlall':'UTF-8'}',
items: [
{foreach from=$content_products item=product name=products}
{
item_id: '{$product.content_ids|escape:'htmlall':'UTF-8'}',
item_name: '{$product.name|escape:'htmlall':'UTF-8'}',
coupon: '{$product.content_coupon|escape:'htmlall':'UTF-8'}',
discount: {$product.discount|escape:'htmlall':'UTF-8'},
index: {$smarty.foreach.products.index},
item_list_name: 'Cart products',
item_list_id: 1,
affiliation: '{$http_referer|escape:'htmlall':'UTF-8'}',
item_brand: '{$product.manufacturer_name|escape:'htmlall':'UTF-8'}',
item_category: '{$product.content_category|escape:'htmlall':'UTF-8'}',
{if !empty($product.content_category2)}item_category2: '{$product.content_category2|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category3)}item_category3: '{$product.content_category3|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category4)}item_category4: '{$product.content_category4|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category5)}item_category5: '{$product.content_category5|escape:'htmlall':'UTF-8'}',{/if}
item_variant: '{if isset($product.variant)}{$product.variant}{/if}',
price: {$product.price|escape:'htmlall':'UTF-8'},
currency: '{$currency|escape:'htmlall':'UTF-8'}',
quantity: '{$product.cart_quantity|escape:'htmlall':'UTF-8'}'
},
{/foreach}
],
value: {$content_value|escape:'htmlall':'UTF-8'}
});
console.log('Fired up event GA4: view_cart');
gtag('event', 'view_cart', {
currency: '{$currency|escape:'htmlall':'UTF-8'}',
items: [
{foreach from=$content_products item=product name=products}
{
item_id: '{$product.content_ids|escape:'htmlall':'UTF-8'}',
item_name: '{$product.name|escape:'htmlall':'UTF-8'}',
coupon: '{$product.content_coupon|escape:'htmlall':'UTF-8'}',
discount: {$product.discount|escape:'htmlall':'UTF-8'},
index: {$smarty.foreach.products.index},
item_list_name: 'Cart products',
item_list_id: 1,
affiliation: '{$http_referer|escape:'htmlall':'UTF-8'}',
item_brand: '{$product.manufacturer_name|escape:'htmlall':'UTF-8'}',
item_category: '{$product.content_category|escape:'htmlall':'UTF-8'}',
{if !empty($product.content_category2)}item_category2: '{$product.content_category2|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category3)}item_category3: '{$product.content_category3|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category4)}item_category4: '{$product.content_category4|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category5)}item_category5: '{$product.content_category5|escape:'htmlall':'UTF-8'}',{/if}
item_variant: '{if isset($product.variant)}{$product.variant}{/if}',
price: {$product.price|escape:'htmlall':'UTF-8'},
currency: '{$currency|escape:'htmlall':'UTF-8'}',
quantity: '{$product.cart_quantity|escape:'htmlall':'UTF-8'}'
},
{/foreach}
],
value: {$content_value|escape:'htmlall':'UTF-8'}
});
{else if ($tagType === 'category')}
console.log('Fired up event GA4: view_item_list > Category products list page');
gtag('event', 'view_item_list', {
items: [
{foreach from=$content_products item=product name=products}
{
item_id: '{$product.content_ids|escape:'htmlall':'UTF-8'}',
item_name: '{$product.product_name|escape:'htmlall':'UTF-8'}',
coupon: '{$product.content_coupon|escape:'htmlall':'UTF-8'}',
discount: {$product.discount|escape:'htmlall':'UTF-8'},
index: {$smarty.foreach.products.index},
item_list_name: '{$content_name|escape:'htmlall':'UTF-8'}',
item_list_id: '{$page|escape:'htmlall':'UTF-8'}',
affiliation: '{$http_referer|escape:'htmlall':'UTF-8'}',
item_brand: '{$product.manufacturer|escape:'htmlall':'UTF-8'}',
item_category: '{$content_category|escape:'htmlall':'UTF-8'}',
{if !empty($content_category2)}item_category2: '{$content_category2|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($content_category3)}item_category3: '{$content_category3|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($content_category4)}item_category4: '{$content_category4|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($content_category5)}item_category5: '{$content_category5|escape:'htmlall':'UTF-8'}',{/if}
item_variant: '{if isset($product.variant)}{$product.variant}{/if}',
price: {$product.price_amount|escape:'htmlall':'UTF-8'},
currency: '{$currency|escape:'htmlall':'UTF-8'}',
quantity: 1
},
{/foreach}
],
item_list_name: '{$content_name|escape:'htmlall':'UTF-8'}',
item_list_id: '{$page|escape:'htmlall':'UTF-8'}'
});
{else if ($tagType === 'prices-drop')}
console.log('Fired up event GA4: view_promotion > Products list prices drop page');
gtag('event', 'view_promotion', {
items: [
{foreach from=$content_products item=product name=products}
{
item_id: '{$product.content_ids|escape:'htmlall':'UTF-8'}',
item_name: '{$product.product_name|escape:'htmlall':'UTF-8'}',
coupon: '{$product.content_coupon|escape:'htmlall':'UTF-8'}',
discount: {$product.discount|escape:'htmlall':'UTF-8'},
index: {$smarty.foreach.products.index},
item_list_name: '{$content_name|escape:'htmlall':'UTF-8'}',
item_list_id: '{$page|escape:'htmlall':'UTF-8'}',
affiliation: '{$http_referer|escape:'htmlall':'UTF-8'}',
item_brand: '{$product.manufacturer|escape:'htmlall':'UTF-8'}',
item_category: '{$product.content_category|escape:'htmlall':'UTF-8'}',
{if !empty($product.content_category2)}item_category2: '{$product.content_category2|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category3)}item_category3: '{$product.content_category3|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category4)}item_category4: '{$product.content_category4|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category5)}item_category5: '{$product.content_category5|escape:'htmlall':'UTF-8'}',{/if}
item_variant: '{if isset($product.variant)}{$product.variant}{/if}',
price: {$product.price_amount|escape:'htmlall':'UTF-8'},
currency: '{$currency|escape:'htmlall':'UTF-8'}',
quantity: 1
},
{/foreach}
],
item_list_name: '{$content_name|escape:'htmlall':'UTF-8'}',
item_list_id: '{$page|escape:'htmlall':'UTF-8'}'
});
console.log('Fired up event GA4: view_item_list > Products list prices drop page');
gtag('event', 'view_item_list', {
items: [
{foreach from=$content_products item=product name=products}
{
item_id: '{$product.content_ids|escape:'htmlall':'UTF-8'}',
item_name: '{$product.product_name|escape:'htmlall':'UTF-8'}',
coupon: '{$product.content_coupon|escape:'htmlall':'UTF-8'}',
discount: {$product.discount|escape:'htmlall':'UTF-8'},
index: {$smarty.foreach.products.index},
item_list_name: '{$content_name|escape:'htmlall':'UTF-8'}',
item_list_id: '{$page|escape:'htmlall':'UTF-8'}',
affiliation: '{$http_referer|escape:'htmlall':'UTF-8'}',
item_brand: '{$product.manufacturer|escape:'htmlall':'UTF-8'}',
item_category: '{$product.content_category|escape:'htmlall':'UTF-8'}',
{if !empty($product.content_category2)}item_category2: '{$product.content_category2|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category3)}item_category3: '{$product.content_category3|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category4)}item_category4: '{$product.content_category4|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category5)}item_category5: '{$product.content_category5|escape:'htmlall':'UTF-8'}',{/if}
item_variant: '{if isset($product.variant)}{$product.variant}{/if}',
price: {$product.price_amount|escape:'htmlall':'UTF-8'},
currency: '{$currency|escape:'htmlall':'UTF-8'}',
quantity: 1
},
{/foreach}
],
item_list_name: '{$content_name|escape:'htmlall':'UTF-8'}',
item_list_id: '{$page|escape:'htmlall':'UTF-8'}'
});
{else if ($tagType === 'best-sales')}
console.log('Fired up event GA4: view_item_list > Products best-sales list page');
gtag('event', 'view_item_list', {
items: [
{foreach from=$content_products item=product name=products}
{
item_id: '{$product.content_ids|escape:'htmlall':'UTF-8'}',
item_name: '{$product.product_name|escape:'htmlall':'UTF-8'}',
coupon: '{$product.content_coupon|escape:'htmlall':'UTF-8'}',
discount: {$product.discount|escape:'htmlall':'UTF-8'},
index: {$smarty.foreach.products.index},
item_list_name: '{$content_name|escape:'htmlall':'UTF-8'}',
item_list_id: '{$page|escape:'htmlall':'UTF-8'}',
affiliation: '{$http_referer|escape:'htmlall':'UTF-8'}',
item_brand: '{$product.manufacturer|escape:'htmlall':'UTF-8'}',
item_category: '{$product.content_category|escape:'htmlall':'UTF-8'}',
{if !empty($product.content_category2)}item_category2: '{$product.content_category2|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category3)}item_category3: '{$product.content_category3|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category4)}item_category4: '{$product.content_category4|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category5)}item_category5: '{$product.content_category5|escape:'htmlall':'UTF-8'}',{/if}
item_variant: '{if isset($product.variant)}{$product.variant}{/if}',
price: {$product.price_amount|escape:'htmlall':'UTF-8'},
currency: '{$currency|escape:'htmlall':'UTF-8'}',
quantity: 1
},
{/foreach}
],
item_list_name: '{$content_name|escape:'htmlall':'UTF-8'}',
item_list_id: '{$page|escape:'htmlall':'UTF-8'}'
});
{else if ($tagType === 'new-products')}
console.log('Fired up event GA4: view_item_list > New products list page');
gtag('event', 'view_item_list', {
items: [
{foreach from=$content_products item=product name=products}
{
item_id: '{$product.content_ids|escape:'htmlall':'UTF-8'}',
item_name: '{$product.product_name|escape:'htmlall':'UTF-8'}',
coupon: '{$product.content_coupon|escape:'htmlall':'UTF-8'}',
discount: {$product.discount|escape:'htmlall':'UTF-8'},
index: {$smarty.foreach.products.index},
item_list_name: '{$content_name|escape:'htmlall':'UTF-8'}',
item_list_id: '{$page|escape:'htmlall':'UTF-8'}',
affiliation: '{$http_referer|escape:'htmlall':'UTF-8'}',
item_brand: '{$product.manufacturer|escape:'htmlall':'UTF-8'}',
item_category: '{$product.content_category|escape:'htmlall':'UTF-8'}',
{if !empty($product.content_category2)}item_category2: '{$product.content_category2|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category3)}item_category3: '{$product.content_category3|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category4)}item_category4: '{$product.content_category4|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category5)}item_category5: '{$product.content_category5|escape:'htmlall':'UTF-8'}',{/if}
item_variant: '{if isset($product.variant)}{$product.variant}{/if}',
price: {$product.price_amount|escape:'htmlall':'UTF-8'},
currency: '{$currency|escape:'htmlall':'UTF-8'}',
quantity: 1
},
{/foreach}
],
item_list_name: '{$content_name|escape:'htmlall':'UTF-8'}',
item_list_id: '{$page|escape:'htmlall':'UTF-8'}'
});
{else if ($tagType === 'search')}
console.log('Fired up event GA4: search');
gtag('event', 'search', {
search_term: '{$search_string|escape:'htmlall':'UTF-8'}',
});
{else if ($tagType === 'cms')}
console.log('Fired up event: view_item');
gtag('event', 'view_item', {
item_name: 'Cms page: {$content_name|escape:'htmlall':'UTF-8'}',
item_id: {$content_ids|escape:'htmlall':'UTF-8'}
});
{else if ($tagType === 'other')}
console.log('Fired up event: view_item');
gtag('event', 'view_item', {
item_name: '{$content_name|escape:'htmlall':'UTF-8'}',
item_id: '{$content_ids|escape:'htmlall':'UTF-8'}'
});
{/if}
{if isset($account_created) && $account_created}
console.log('Fired up event GA4: sign_up');
gtag('event', 'sign_up', {
method: '{$registration_content_name|escape:'htmlall':'UTF-8'}'
});
{/if}
</script>
<!-- PD Google Analytycs 4 Pro - EVENTS CODE FOOTER -->
{/if}

View File

@@ -0,0 +1,57 @@
{*
* 2012-2022 Patryk Marek PrestaDev.pl
*
* Patryk Marek PrestaDev.pl - PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module © All rights reserved.
*
* DISCLAIMER
*
* Do not edit, modify or copy this file.
* If you wish to customize it, contact us at info@prestadev.pl.
*
* @author Patryk Marek <info@prestadev.pl>
* @copyright 2012-2022 Patryk Marek @ PrestaDev.pl
* @license Do not edit, modify or copy this file, if you wish to customize it, contact us at info@prestadev.pl.
* @link http://prestadev.pl
* @package PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module
* @version 1.0.1
* @date 01-05-2021
*}
{if isset($pd_google_analytics_id)}
<!-- START > PD Google Analytycs 4.0 Module -->
<script async data-keepinline="true" src="https://www.googletagmanager.com/gtag/js?id={$pd_google_analytics_id nofilter}"></script>
{literal}
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{/literal}{$pd_google_analytics_id nofilter}{literal}', {
'send_page_view': {/literal}{$pd_google_analytics_spv nofilter}{if isset($pd_google_analytics_aec) && $pd_google_analytics_aec},
{literal}'allow_enhanced_conversions': {/literal}{$pd_google_analytics_aec nofilter}{/if}{literal}});
{/literal}{if isset($pd_google_analytics_id2) && !empty($pd_google_analytics_id2)}{literal}gtag('config', '{/literal}{$pd_google_analytics_id2 nofilter}{literal}', {
'send_page_view': {/literal}{$pd_google_analytics_spv nofilter}{if isset($pd_google_analytics_aec) && $pd_google_analytics_aec},
{literal}'allow_enhanced_conversions': {/literal}{$pd_google_analytics_aec nofilter}{/if}{literal}});
{/literal}{/if}{literal}gtag('set', {'currency': {/literal}"{$pd_google_analytics_currency_iso nofilter}"{literal}});
gtag('set', {'country': {/literal}"{$pd_google_analytics_country_iso nofilter}"{literal}});
{/literal}{if !empty($pd_google_analytics_id_aw) && !empty($pd_google_analytics_id_aw_label)}{literal}gtag('config', '{/literal}{$pd_google_analytics_id_aw nofilter}{literal}');
{/literal}{/if}
{if isset($pd_google_analytics_aec) && $pd_google_analytics_aec != 'false' && !empty($pd_google_analytics_city)}
gtag('set', 'user_data', {
{if !empty($pd_google_analytics_email)}{literal}"email": "{/literal}{$pd_google_analytics_email nofilter}",{/if}
{if !empty($pd_google_analytics_phone)}{literal}"phone_number": "{/literal}{$pd_google_analytics_phone nofilter}"{/if},
{literal}"address": {{/literal}
{if !empty($pd_google_analytics_firstname)}{literal}"first_name": "{/literal}{$pd_google_analytics_firstname nofilter}",{/if}
{if !empty($pd_google_analytics_lastname)}{literal}"last_name": "{/literal}{$pd_google_analytics_lastname nofilter}",{/if}
{if !empty($pd_google_analytics_street)}{literal}"street": "{/literal}{$pd_google_analytics_street nofilter}",{/if}
{if !empty($pd_google_analytics_city)}{literal}"city": "{/literal}{$pd_google_analytics_city nofilter}",{/if}
{if !empty($pd_google_analytics_postcode)}{literal}"postal_code": "{/literal}{$pd_google_analytics_postcode nofilter}",{/if}
{if !empty($pd_google_analytics_country)}{literal}"country": "{/literal}{$pd_google_analytics_country nofilter}"{/if}
}
});
{/if}
</script>
<!-- END > PD Google Analytycs 4.0 Module -->
{/if}

View File

@@ -0,0 +1,67 @@
{*
* 2012-2022 Patryk Marek PrestaDev.pl
*
* Patryk Marek PrestaDev.pl - PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module © All rights reserved.
*
* DISCLAIMER
*
* Do not edit, modify or copy this file.
* If you wish to customize it, contact us at info@prestadev.pl.
*
* @author Patryk Marek <info@prestadev.pl>
* @copyright 2012-2022 Patryk Marek @ PrestaDev.pl
* @license Do not edit, modify or copy this file, if you wish to customize it, contact us at info@prestadev.pl.
* @link http://prestadev.pl
* @package PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module
* @version 1.0.2
* @date 01-05-2021
*}
<!-- PD Google Analytycs 4 Pro - EVENT > purchase -->
<script type="text/javascript" data-keepinline="true">
console.log('Fired up event GA4: purchase');
gtag('event', 'purchase', {
affiliation: '{$http_referer|escape:'htmlall':'UTF-8'}',
coupon: '{$content_coupon|escape:'htmlall':'UTF-8'}',
currency: '{$currency|escape:'htmlall':'UTF-8'}',
items: [
{foreach from=$content_products item=product name=products}
{
item_id: '{$product.content_ids|escape:'htmlall':'UTF-8'}',
item_name: '{$product.product_name|escape:'htmlall':'UTF-8'}',
coupon: '{$product.content_coupon|escape:'htmlall':'UTF-8'}',
discount: {$product.discount|escape:'htmlall':'UTF-8'},
index: {$smarty.foreach.products.index},
affiliation: '{$http_referer|escape:'htmlall':'UTF-8'}',
item_brand: '{$product.manufacturer|escape:'htmlall':'UTF-8'}',
item_category: '{$product.content_category|escape:'htmlall':'UTF-8'}',
{if !empty($product.content_category2)}item_category2: '{$product.content_category2|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category3)}item_category3: '{$product.content_category3|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category4)}item_category4: '{$product.content_category4|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category5)}item_category5: '{$product.content_category5|escape:'htmlall':'UTF-8'}',{/if}
item_variant: '{if isset($product.variant)}{$product.variant}{/if}',
price: {$product.price|escape:'htmlall':'UTF-8'},
currency: '{$currency|escape:'htmlall':'UTF-8'}',
quantity: '{$product.product_quantity|escape:'htmlall':'UTF-8'}'
},
{/foreach}
],
transaction_id: '{$content_transaction_id|escape:'htmlall':'UTF-8'}',
shipping: {$content_shipping|escape:'htmlall':'UTF-8'},
value: {$content_value|escape:'htmlall':'UTF-8'},
tax: {$content_tax|escape:'htmlall':'UTF-8'}
});
{if !empty($pd_google_analytics_id_aw) && !empty($pd_google_analytics_id_aw_label)}
console.log('Fired up event Gtag: Ads / Adwords conversion');
gtag('event', 'conversion', {
'send_to': '{$pd_google_analytics_id_aw|escape:'htmlall':'UTF-8'}/{$pd_google_analytics_id_aw_label|escape:'htmlall':'UTF-8'}',
'value': '{$content_value|escape:'htmlall':'UTF-8'}',
'currency': '{$currency|escape:'htmlall':'UTF-8'}',
'transaction_id': '{$content_transaction_id|escape:'htmlall':'UTF-8'}'
});
{/if}
</script>
<!-- PD Google Analytycs 4 Pro - EVENT > purchase -->

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2012-2022 Patryk Marek PrestaDev.pl
*
* Patryk Marek PrestaDev.pl - PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module © All rights reserved.
*
* DISCLAIMER
*
* Do not edit, modify or copy this file.
* If you wish to customize it, contact us at info@prestadev.pl.
*
* @author Patryk Marek <info@prestadev.pl>
* @copyright 2012-2022 Patryk Marek @ PrestaDev.pl
* @license Do not edit, modify or copy this file, if you wish to customize it, contact us at info@prestadev.pl.
* @link http://prestadev.pl
* @package PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module
* @version 1.0.1
* @date 01-05-2021
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2012-2022 Patryk Marek PrestaDev.pl
*
* Patryk Marek PrestaDev.pl - PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module © All rights reserved.
*
* DISCLAIMER
*
* Do not edit, modify or copy this file.
* If you wish to customize it, contact us at info@prestadev.pl.
*
* @author Patryk Marek <info@prestadev.pl>
* @copyright 2012-2022 Patryk Marek @ PrestaDev.pl
* @license Do not edit, modify or copy this file, if you wish to customize it, contact us at info@prestadev.pl.
* @link http://prestadev.pl
* @package PD Google Analytycs 4.0 Pro 1.6.x and 1.7.x Module
* @version 1.0.1
* @date 01-05-2021
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;