Skip to content

Instantly share code, notes, and snippets.

@troywarr
Last active November 3, 2016 07:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save troywarr/4053ea6c2ef4b535c95d88c815923c2f to your computer and use it in GitHub Desktop.
Save troywarr/4053ea6c2ef4b535c95d88c815923c2f to your computer and use it in GitHub Desktop.
Form tracking with uStudio Oracle Eloqua module
<form>
<p>
<label for="first_name">First Name</label>
<input type="text" id="first_name" name="first_name"/>
</p>
</form>
<script>
window.uStudio.Player.registerPlayerCallback(function (player) {
player.subscribe('OracleEloqua.ready', function () {
$('form').submit(function (event) {
var $input = $('input'),
name = $input.attr('name'),
value = $input.val(),
_this = this;
event.preventDefault();
player.broadcast('OracleEloqua.trackEvent', [name, value]); // tracks `http://www.example.com/?_ustelq_event=first_name&_ustelq_value=Troy`
setTimeout(function () { // give the tracking request some time to complete (only needed if the form's action redirects the page)
_this.submit();
}, 1000);
});
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment