Skip to content

Instantly share code, notes, and snippets.

@TimFletcher
Last active August 23, 2017 23:18
Show Gist options
  • Save TimFletcher/357bf1a30f3bacd4406e83646bcb0fa6 to your computer and use it in GitHub Desktop.
Save TimFletcher/357bf1a30f3bacd4406e83646bcb0fa6 to your computer and use it in GitHub Desktop.
// Requirements: You need to have the heddels snippet installed on every page so that the `tap` function exists
// NOTE: This is untested code!!!
// Bind an event handler for a successful Gravity forms submission
// https://www.gravityhelp.com/documentation/article/gform_confirmation_loaded/
jQuery(document).bind('gform_confirmation_loaded', function(event, formId){
// If you have any forms you DO NOT want this to run for, exclude them here
var excludedFormIds = [];
if (jQuery.inArray(formId, excludedFormIds)) return;
// If the tap function isn't defined, exit early.
if (typeof tap === 'undefined') return;
// Get the amount from the form
var id = (Math.random() + 1).toString(36).substring(2,7);
var total = jQuery('.ginput_total').text(); // e.g. "$905.00"
total = total.replace('$', '');
total = total.split('.')[0];
// Create the conversion
tap('conversion', 'falcon-garments-' + id , total, { program_group: 'falcon-garments' });
});
<script src="//static.tapfiliate.com/tapfiliate.js" type="text/javascript" async></script>
<script type="text/javascript">
window['TapfiliateObject'] = i = 'tap';
window[i] = window[i] || function () {
(window[i].q = window[i].q || []).push(arguments);
};
tap('create', '2708-dea145');
tap('detectClick');
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment