Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

If you are using the Contact Form 7 plugin for contact forms, you can use the instructions below to sync the content of the forms to Squeezely via tag manager.

Retrieving IDs

Every contact form has a unique ID, and every field in it has its own ID as well. We need both and you can retrieve them as follows: open the page with the contactform, and then open the console (ctrl-shift-j). Paste the code below into the console:

Code Block
document.addEventListener( 'wpcf7submit', function( event ) {



This will result in the following example:

dc4c061a-2197-4081-8c53-f3e105b286de#media-blob-url=true&id=434f1c8b-3d49-4b3b-bce7-11825602795e&contextId=22764&collection=Image Added

Here we see that the form ID is 24, and the fields name and e-mail have respectively 1 and 2 as ID

Creating a tag

Create a custom HTML tag in GTM, using the script below:

Code Block
<script type="text/javascript">

  document.addEventListener( 'wpcf7submit', function( event ) {
         if (event.detail.contactFormId == 24 ) {
       var input = event.detail.inputs;
       var fullName = input[2].value.split(' ');
       var firstName = fullName[0];
       var lastName = fullName[fullName.length - 1];
          "event" : "Contact",
          "firstname" : firstName,
          "lastname" : lastName,
          "email" : input[4].value


Change 24 to your form ID. Next we retrieve all submitted information and place it in the array 'input'. You can retrieve individual field names by addressing an element as follows: input[2] if we want to send the second field, in this case email.

In this example, the name field in the form does not have a first name and last name split, so we added a script to split that as well. If the field is a direct match, you don't need to create any extra variables and you can just do it like this: "email" : input[4].value.

We then send the name and email in a custom event titled Contact. The trigger for this form is the page view where the form is on, since this script is an event listener it will only really execute when the form is submitted. If you place it on the button click, the event listener may act too late