$(function () { var str = document.location.href; var suffix = "/confirmation"; if (str.indexOf(suffix, str.length - suffix.length) == -1) { $('a.conversion_goal, div.conversion_goal').bind('mousedown', function (e) { if (e.button == 0 || e.button == 1) { var isPayPalButton = this.tagName == 'DIV'; var conversionParam = this.id.split('&').slice(-1)[0]; var isConversion = conversionParam.split('=')[0] == 'IsConversion' && conversionParam.split('=')[1] == 'True'; // If the user clicks the link with the middle button or presses the ctrl key, or opens the link in a new tab, // then post the tracking event. if (!isPayPalButton && (e.button == 1 || e.ctrlKey || $(this).attr('target') == '_blank')) { if (isConversion && typeof _lrx_sendEvent === "function") { _lrx_sendEvent('conversion', 'LANDER-LINK-' + 'Link Clicks'); } $.post('/Lander/Home/LinkClicked?' + this.id); } // If the user opens the link in the same window, post the tracking event and redirect after the request is already complete. else if (e.button != 1 && isPayPalButton || !isPayPalButton) { $(this).click(function (clickEvent) { clickEvent.preventDefault(); }); if (isPayPalButton) { var parentForm = $(this).parent().parent(); if (isConversion && typeof _lrx_sendEvent === "function") { _lrx_sendEvent('conversion', 'LANDER-ECOMMERCE-' + 'E-Commerce Actions'); } parentForm.attr("target", "_blank"); parentForm.submit(); } else if (isConversion && typeof _lrx_sendEvent === "function") { _lrx_sendEvent('conversion', 'LANDER-LINK-' + 'Link Clicks'); } var url = $(this).attr('href'); $.post('/Lander/Home/LinkClicked?' + this.id).complete(function () { if (!isPayPalButton) { document.location = url; } }); } } }); } else { $('div.conversion_goal').bind('mousedown', function (e) { if (e.button == 0) { $(this).parent().parent().attr("target", "_blank"); $(this).parent().parent().submit(); } }); } // Remove the event from the form button. $('form div a').unbind('mousedown'); });