Title: Google Analytics Tracking Multiple Forms
Last modified: June 5, 2017

---

# Google Analytics Tracking Multiple Forms

 *  Resolved [nturne](https://wordpress.org/support/users/nturne/)
 * (@nturne)
 * [9 years ago](https://wordpress.org/support/topic/google-analytics-tracking-multiple-forms/)
 * Hi
 * I see that using the ‘on_sent_ok’ hook is to be abolished and that the recommendation
   for tracking form submissions in Google Analytics is now to add the event tracking
   code to the page head ([https://contactform7.com/tracking-form-submissions-with-google-analytics/](https://contactform7.com/tracking-form-submissions-with-google-analytics/)).
   However, the suggestion does not allow for tracking different forms as different
   events. For example, if I have a standard contact form and a quote request form
   on the same page which I would like to track separately.
 * Please could you suggest how this could be worked?
 * Thanks

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [nturne](https://wordpress.org/support/users/nturne/)
 * (@nturne)
 * [9 years ago](https://wordpress.org/support/topic/google-analytics-tracking-multiple-forms/#post-9202160)
 * I think I’ve answered my own question…
 * I have added the following to my child theme functions.php file and it appears
   to work:
 *     ```
       function hook_google_analytics() {
       	echo "<script>\r\n";
       	echo "document.addEventListener('wpcf7mailsent', function(event) {\r\n";
       	echo "	if ( '5' == event.detail.contactFormId ) {\r\n";
       	echo "		ga('send', 'event', 'Contact Form', 'Submit');\r\n";
       	echo "	} else if ( '179' == event.detail.contactFormId ) {\r\n";
       	echo "		ga('send', 'event', 'Quote Reservation', 'Submit');\r\n";
       	echo "	}\r\n";
       	echo "}, false );\r\n";
       	echo "</script>\r\n";
       }
       add_action('wp_head', 'hook_google_analytics');
       ```
   
 * In this case the standard contact form has an ID of ‘5’ and the quote form has
   an ID of ‘179’ (taken from the shortcode).
 * Any comments would be appreciated.
 *  [danielgc](https://wordpress.org/support/users/danielgc/)
 * (@danielgc)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/google-analytics-tracking-multiple-forms/#post-9406150)
 * Hello nturne! I have the same question, did your solution work? Does it appear
   on your analytics results?
 *  Thread Starter [nturne](https://wordpress.org/support/users/nturne/)
 * (@nturne)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/google-analytics-tracking-multiple-forms/#post-9407788)
 * Hello danielgc. I believe it works OK, but it hasn’t been subjected to rigorous
   testing yet – the only website that I needed to install it on is a very small(
   and low traffic) website, but I haven’t had an issue so far. If you try it yourself
   and later have any feedback, maybe you could post it?
 *  [danielgc](https://wordpress.org/support/users/danielgc/)
 * (@danielgc)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/google-analytics-tracking-multiple-forms/#post-9409700)
 * Thx nturne, I ended using a different technique: [https://wordpress.org/support/topic/event-detail-contactformname-or-something-similar/](https://wordpress.org/support/topic/event-detail-contactformname-or-something-similar/)
 * best regards!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Google Analytics Tracking Multiple Forms’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [danielgc](https://wordpress.org/support/users/danielgc/)
 * Last activity: [8 years, 10 months ago](https://wordpress.org/support/topic/google-analytics-tracking-multiple-forms/#post-9409700)
 * Status: resolved