Title: Google Analytics event tracking
Last modified: August 21, 2016

---

# Google Analytics event tracking

 *  Resolved [eizymeizy_0809](https://wordpress.org/support/users/eizymeizy_0809/)
 * (@eizymeizy_0809)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/google-analytics-event-tracking-1/)
 * Is it possible to send an “event” to Google Universal Analytics to track goals?
   So that when someone clicks the “Submit” button, the event is tracked in Analytics.
 * Google Analytics documentation here: [https://developers.google.com/analytics/devguides/collection/analyticsjs/events](https://developers.google.com/analytics/devguides/collection/analyticsjs/events)
   but I didn’t understand which code to put in your submit button code..?
 * [https://wordpress.org/plugins/mailchimp-for-wp/](https://wordpress.org/plugins/mailchimp-for-wp/)

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

 *  Plugin Author [Danny van Kooten](https://wordpress.org/support/users/dvankooten/)
 * (@dvankooten)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/google-analytics-event-tracking-1/#post-4690387)
 * If you load the _Analytics.js_ file in your pages, you should be able to track
   form submissions with something like the following.
 * **JavaScript**
 *     ```
       var submitButton = document.querySelector('.mc4wp-form input[type="submit"]');
       addListener(submitButton, 'click', function() {
         ga('send', 'event', 'button', 'click', 'nav-buttons');
       });
   
       // helper function to add listeners (cross-browser compatible)
       function addListener(element, type, callback) {
        if (element.addEventListener) element.addEventListener(type, callback);
        else if (element.attachEvent) element.attachEvent('on' + type, callback);
       }
       ```
   
 * You can drop that code anywhere in your JS files. If you have no clue how to 
   do this, an easier way might be to stick to HTML only.
 * Form mark-up:
 *     ```
       <input type="submit" value="Subscribe" onclick="ga('send', 'event', 'button', 'click', 'nav-buttons');" />
       ```
   
 *  Thread Starter [eizymeizy_0809](https://wordpress.org/support/users/eizymeizy_0809/)
 * (@eizymeizy_0809)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/google-analytics-event-tracking-1/#post-4690435)
 * That should solve it (the HTML version). Great, thanks!

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

The topic ‘Google Analytics event tracking’ is closed to new replies.

 * ![](https://ps.w.org/mailchimp-for-wp/assets/icon-256x256.png?rev=1224577)
 * [MC4WP: Mailchimp for WordPress](https://wordpress.org/plugins/mailchimp-for-wp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mailchimp-for-wp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mailchimp-for-wp/)
 * [Active Topics](https://wordpress.org/support/plugin/mailchimp-for-wp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mailchimp-for-wp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mailchimp-for-wp/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [eizymeizy_0809](https://wordpress.org/support/users/eizymeizy_0809/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/google-analytics-event-tracking-1/#post-4690435)
 * Status: resolved