# Google Tag Manager : Tracking of Ajax actions

> The few following lines will explain you how to setup your Google Tag Manager to track conversions from an Ajax form, when the default action of the form is stopped (\`preventDefault()\`) by JavaScript code.

Source: https://antistatique.net/en/blog/google-tag-manager-tracking-of-ajax-actions-en

Category: Strategy

# Google Tag Manager : Tracking of Ajax actions

Author(s)

[

![Kevin](https://images.statique.ch/t/w_750,h_750,c_fill,f_jpeg,q_70/wp/app/uploads/2020/12/Kevin-300x300.jpg)



](/en/agence/kevin)[

![Noémie](https://images.statique.ch/t/w_750,h_750,c_fill,f_jpeg,q_70/wp/app/uploads/2020/12/No%C3%A9mie-300x300.jpg)



](/en/agence/noemie)

[Kevin](/en/agence/kevin) and [Noémie](/en/agence/noemie)6 March 2018

5 minutes read.

_Warning : this article is intended for people that have interest for the setup of statistics and tracking tools, and to all curious people_.

The trackingwith a capital T, has become very easy with the emergence of [Google Tag Manager](https://www.google.com/intl/fr/analytics/tag-manager/) (GTM).

In a simple use case, you can track multiple type of actions like an event, a page view, a transaction, etc.

In the case of an event, like submitting a form, it is sometimes required to monitor the click on a button. For this we usually choose the trigger type "_Elements - Clicks_" or "_Link_". We can then specify which Button (or Link) the code must track by specifying a class, an ID or it's target, for example.

![Type de déclencheur](https://images.statique.ch/t/w_750,f_jpeg,q_70/wp/app/uploads/2020/12/gtm-clic-1024x374.png)

Sadly, it sometimes happens that these standard methods are not enough for one of the following reasons:

-   You element (form) is loaded through AJAX, after the initial page load.
-   The default action (Click on the button or the link) is stopped (\`preventDefault()\`).

The few following lines will explain you how touse **Google Tag Manager to track conversions from an Ajax form**, when the default action of the form is stopped (`preventDefault()`) by JavaScript code. Once you will have understood this concept, you’ll see that the method we present you can apply to many other specific cases, like the tracking of elements loaded asynchronously after the initial page load.

## Use Case

Before we begin, here is the example form we will be using to demonstrate our experimentation.

Let’s use a rather simple form with two fields.

-   Your name
    
-   Your Email address
    
-   Votre nom
    
-   Votre adresse e-mail
    

By clicking on the **send** button, an AJAX call is sent and the button default action is stopped with the help of the function `preventDefault()`.

## Tag creation in GTM

In GTM, you can create a tag for the event, as you usually do.

![GTM - Event](https://images.statique.ch/t/w_750,f_jpeg,q_70/wp/app/uploads/2020/12/modulo-1024x267.png)

## Creation of your Data Layout Event Code

Once your tag ready to use, we will have to add a thin layer of javascript code to your form, so that it triggers the _Google Tag Manager Custom Event_. This custom event will allow us to communicate for GTM to inform it of our form submission.

Keep in mind the value of the key `event`, as we will soon need it.

Once the code is implemented in you page, you can proceed to the next step.

## Creation of the trigger in GTM

In GTM the trigger type required is "_Custom Event_ ». Remember the `event` key we asked you to keep in mind? Now we need it! Input this key as the name of the trigger we just created. You can then link your tag to this trigger, save it, and pass in "_Preview_ » mode to test our implementation.

![Custom Event](https://images.statique.ch/t/w_750,f_jpeg,q_70/wp/app/uploads/2020/12/gtm-custom-1024x331.png)

Here you go, your event works as intended, event with your AJAX layer!

**Unlike what we could think, collaboration between the developers and the marketing team has a bright future!**

## Sources

For the most curious of you, here are some complementary information sources that have inspired this article’s creation.

**Julius Fed** (13 août 2017). GTM Custom Event Trigger Explained.  
Retrieved from [analyticsmania.com](https://www.analyticsmania.com/post/google-tag-manager-custom-event-trigger)

**Richard Egloff** (02 octobre 2014). Google Tag Manager: Tracking of AJAX Forms.  
Retrieved from [amazeemetrics.com](https://www.amazeemetrics.com/en/blog/google-tag-manager-tracking-ajax-forms)

## More articles

Author(s)

[

![Marc](https://images.statique.ch/t/w_750,h_750,c_fill,f_jpeg,q_70/wp/app/uploads/2020/12/Marc-300x300.jpg)



](/en/agence/marc)

[Marc](/en/agence/marc)28 August 2025

### [How do you choose your web agency?](/en/blog/how-do-you-choose-your-web-agency)

As clients, when you pitch, it’s to build a close relationship. Have you ever considered reversing the roles during the proposal review?

As clients, when you pitch, it’s to build a close relationship. Have you ever considered reversing the roles during the proposal review?

[

![How do you choose your web agency?](https://images.statique.ch/t/w_750,h_500,c_fill,f_jpeg,q_70/wp/app/uploads/2025/08/chat_salon_antistatique-768x576.jpeg)



](/en/blog/how-do-you-choose-your-web-agency)

Author(s)

[

![Alberto](https://images.statique.ch/t/w_750,h_750,c_fill,f_jpeg,q_70/wp/app/uploads/2025/08/alberto_profile_head.jpg)



](/en/agence/alberto)

[Alberto](/en/agence/alberto)26 August 2025

### [ChatGPT, your mom.](/en/blog/chatgpt-your-mom)

ChatGPT, I love you, me neither.

ChatGPT, I love you, me neither.

[

![ChatGPT, your mom.](https://images.statique.ch/t/w_750,h_500,c_fill,f_jpeg,q_70/wp/app/uploads/2025/08/0_big.png)



](/en/blog/chatgpt-your-mom)

Author(s)

[

![Susana](https://images.statique.ch/t/w_750,h_750,c_fill,f_jpeg,q_70/wp/app/uploads/2022/09/Susana-2-300x300.jpg)



](/en/agence/susana-rodrigues)

[Susana](/en/agence/susana-rodrigues)12 August 2024

### [Optimising Your Content for Better SEO: The Complete Guide](/en/blog/optimising-your-content-for-better-seo-the-complete-guide)

Organic search (SEO) has become an essential element for any company looking to increase its visibility on the web. At the heart of this strategy, content optimisation plays a key role.

Organic search (SEO) has become an essential element for any company looking to increase its visibility on the web. At the heart of this strategy, content optimisation plays a key role.
