Triggering Elementor Form Successful Submissions in Google Tag Manager

When using analytical tools like Google Analytics or Mixpanel on your website, you may need to track successful Elementor form submissions. Since there is no default event for this, many people attempt to trigger an event based on clicks on the submit button. However, this will trigger on every click, not just when the form is successfully submitted.

We explored many solutions, but adding a Data Layer with a new event worked best for us. All you need to do is copy and paste this small code into your Elementor Custom Code:

<script>
  jQuery(document).ready(function ($) {
    $(document).on('submit_success', function (evt) {
      window.dataLayer = window.dataLayer || [];
      window.dataLayer.push({
        event: 'form_sent',
        form_name: evt.target.name
      });
    });
  });
</script>

Once this code is added, the form_sent event will appear every time an Elementor form on your website is successfully submitted. The best part of this Data Layer is the form_name, which you can easily use to create a variable in Google Tag Manager to distinguish between different Elementor forms on your website. Just remember to name your Elementor forms.

Picture of Roman Vlčák

Roman Vlčák

An incorrigible perfectionist passionate about pixel-perfect work, who constantly strives to deliver the highest possible quality. Outside of Webgate, he is a caring husband and father to his young son. In his free time, he likes traveling with his family and doing puzzles.

Senior WordPress Developer • Co-founder

Related Articles

Discover how Bloomreach saves 50% of the costs on website development and speeds up marketing activities by 32% thanks to Webgate.

Read more
Blog

Optimizing Bloomreach’s Website Performance

Read more
Blog

Top 5 WordPress Agencies in 2024

Read more
Blog

Subscribe to our quarterly newsletter and receive latest insights.

Topics: Improving B2B websites, AI tools in web development, UX/UI, website marketing trends etc.

By submitting this form you agree to the processing of your personal data according to our .
Services

Thank you for your interest!

We will contact you soon.

Back

Capabilities
Front-end Development
Back-end Development
Low code/No-code
Low code/No-code
Web Design
UI/UX/CX Design