$(".stripe-btn").on('click', function () {
setTracking('Stripe');
let id = $(this).data('id');
let yearly = $(this).data('yearly');
location.href = "integrations/stripe-checkout.php?plan=" + id + "&yearly=" + yearly;
});
$(".paypal-btn").on('click', function () {
setTracking('Paypal');
let id = $(this).data('id');
let yearly = $(this).data('yearly');
location.href = "integrations/paypal-checkout.php?plan=" + id + "&yearly=" + yearly;
});
function getPageUrl(url) {
url = url.split('/');
if (url.length > 4) {
url = 'sitemaps';
} else {
let lastIndex = url[url.length - 1];
if (lastIndex[0] == '#') {
url = url[url.length - 2];
} else {
url = url[url.length - 1];
}
if (url != '')
url = url.split('.')[0];
else
url = 'index';
}
return url;
}
function setTracking(method) {
let url = getPageUrl(window.location.href);
$.ajax({
type: "POST",
url: "tracking.php",
data: {
func: 'setAction',
section: method + ' Payment',
action: 'Submit',
page: url
},
async: false
})
.done(function () {
})
.error(function (e, err) {
})
.always(function () {
});
}