Created
July 19, 2014 20:04
-
-
Save atwellpub/3b845b3b6dc09bf07427 to your computer and use it in GitHub Desktop.
Call to Action link tracking support for LeadBoxes Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Call to Action Support for LeadBoxes | |
* adds click tracking listeners to call to action links containing the 'leadbox-track-me' class id. | |
*/ | |
add_action('wp_footer' , 'inbound_cta_leadboxes_tracking'); | |
function inbound_cta_leadboxes_tracking() { | |
?> | |
<script type='text/javascript'> | |
jQuery( document ).ready( function() { | |
jQuery("body").on('click', '.leadbox-track-me', function (e) { | |
var cta_id = jQuery(this).attr("data-event-id"); | |
var vid = jQuery(this).attr("data-cta-variation"); | |
e.preventDefault(); // halt normal form | |
jQuery.ajax({ | |
type: 'POST', | |
url: ajaxurl, | |
timeout: 10000, | |
data: { | |
action: 'wp_cta_record_conversion', | |
cta_id: cta_id, | |
variation_id: vid | |
}, | |
success: function(data){ | |
return true; | |
}, | |
error: function(MLHttpRequest, textStatus, errorThrown){ | |
return true; | |
} | |
}); | |
}); | |
}); | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment