Skip to content

Instantly share code, notes, and snippets.

@WengerK
Last active March 2, 2018 16:27
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 WengerK/512ec73df389a9dea720bdc5849f8c05 to your computer and use it in GitHub Desktop.
Save WengerK/512ec73df389a9dea720bdc5849f8c05 to your computer and use it in GitHub Desktop.
Article Ressources - Google Tag Manager: Tracking of Ajax actions

Article Ressources - Google Tag Manager: Tracking of Ajax actions

This is the Gist repository for my article Google Tag Manager: Tracking of Ajax actions.

Be aware that this article has been wrote for the Blog of Antistatique — Web Agency in Lausanne, Switzerland. A place where I work as Full Stack Web Developer.

Feel free to read it the full article on Medium or check it out on Antistatique.

Content of this Gist :

  • datalayer.js : Basic Form Config
  • ajax_form.php : Advanced Form Config
<form id="subscription" name="subscription" action="./" method="POST">
Name: <input type="text" name="Name"><br>
Email: <input type="email" name="Email" required><br>
<input id="buttonToTrack" type="submit" value="Submit">
</form>
<script type="text/javascript">
// When the DOM is fully loaded (jQuery).
$(document).ready(function() {
// Submit the form via ajax.
$("#subscription").ajaxForm();
});
</script>
<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'popinSubmit'
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment