• I recently updated my site to use Google Tag Manager (GTM) and noticed there were problems with the value I had in “Additional Settings” in Contact Form 7 used for tracking events:

    on_sent_ok: “_gaq.push([‘_trackEvent’, ‘Contact Form’, ‘Submit’]);”

    I don’t believe this value is going to work with GTM so the problem is that I would like to track submissions from Contact Form 7 using GTM, but unsure about how to do so.

    I have a few events setup in Google Tag Manager that work, but I’m unsure of how to configure GTM to trigger an event using the on_sent_ok hook.

    Also, I’m not using the Google Tag Manager for WordPress plugin. However, if it would make this process easier, I’m definitely open to it, if recommended.

    Any advice would be greatly appreciate.

    Thanks much for the help!

    -mark

    https://wordpress.org/plugins/contact-form-7/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter Mark3000

    (@mark3000)

    Thought the solution might be helpful for some. It required two steps:

    1. In Google Tag Manager, create a new tag with the following settings:
    -Tag Type = “Universal Analytics” or “Classic Google Analytics”
    -Track Type = “Event”
    -Event Tracking Parameters = User discretion

    2. Add a rule to this tag event that fires when:
    {{event}} equals “gtm4wp.contactForm7Submitted”

    Publish the tag and test.

    Good luck!

    -mark

    Hi Mark,

    Just letting you know your post was really helpful! I used your steps to make it work, but i had to add the following code to the Additional Configuration in Contact Form 7.

    on_sent_ok: “ga(‘send’, ‘event’, ‘category’, ‘action’);”

    Which is a bit different from yours.

    Thanks again!

    Could one of you two please tie the steps together? There are many threads on the topic of tracking CF7 submits as events with the GTM container, but nothing is conclusive and works yet, giving my obvious wrong implementation, and I’m hearing success stories.

    No matter what I add to CF7’s additional settings the tag for the event “gtm4wp.contactForm7Submitted” never triggers. I’m doing something wrong, but can’t identify the disconnect.

    Mark – In your working GTM example, did you use the “additional settings” you already specified or are we to use dollenmetmedia’s? I’ve tried both with no success, so I’m doing something wrong. Please advise.

    Hi TexasTrev,

    Here’s what I did just now with a new website I wanted to track send forms. Note: I’m using Universal Analytics. I didn’t need the {{event}} rule anymore to track form submittions.

    1. I created a form with the following additional settings:
    on_sent_ok: “ga(‘send’, ‘event’, ‘yourcategory’, ‘youraction’, ‘yourlabel’);”

    In my case this was:
    on_sent_ok: “ga(‘send’, ‘event’, ‘forms’, ‘send’, ‘invoices’);”

    2. I added this event as a goal in my Universal Analytics account, like this:
    Category (equal to) : forms
    Action (equal to): send
    Label (equal to): invoices

    You can leave the value field empty.

    3. Add the event tracking to your Google Tag Manager
    This one might be a bit tricky. Hope I can explain it to you correctly. Note: I’m using the new interface for GTM.

    Go to the container for your Tag. You might have set up the standard Universal Analytics tag already, if not, do this first. Then, add a new tag with the following settings:

      Tag: Google Analytics
      Type Tag: Universal
      Tag Activation: All pages (you could specify this to a single page if you wanted)

    Now comes the Tag Configuration. Note to use the exact same fields as used in the Goals in Google Analytics.

      Tag name: Send forms for invoices
      Tracking-ID: Your tracking-ID.
      Category: forms
      Action: send
      Label: invoices

    Save your tag.

    4. Test your container before you publish and check if the tag is fired.
    This is easy. Set your container to ‘test’ and check your website (while leaving the GTM screen open). You should see a pop-up with all the fired tags. If the event tracking is fired, you can now publish your container.

    5. Test some more: the goals in Analytics
    If your contact form is sent, you should be able to see it in your Realtime Conversion. Go to Google Analytics > Realtime > Conversions. Note: make sure you don’t have any IP filters on or anything like that. It becomes frustrating when you find out after a day you couldn’t tracking realtime conversions, because you filtered yourself out.

    Thats it! Hope it worked for you!

    Ok. So..it stopped working for me. Nevermind the post above. #fail

    Well noway – so what now?

    I did post a quite conclusive guide that’ll help you still struggling with this. How to configure Google Tag Manager to send events based on form submits with Contact Form 7, right here: http://dcarlbom.com/google-tag-manager/contact-form-7-on-wordpress-with-gtm/

    @dcarlbom – Thanks for the link to your article. It works!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Using Google Tag Manager with on_sent_ok hook in Contact Form 7’ is closed to new replies.