Title: Google analytics tracking
Last modified: September 30, 2016

---

# Google analytics tracking

 *  Resolved [gabeelliott](https://wordpress.org/support/users/gabeelliott/)
 * (@gabeelliott)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/google-analytics-tracking-9/)
 * Is there some documentation on how to track the leads in our Google analytics?
   Im not using a thank you page redirect on completion of form so need to set it
   up as an event on the button click.

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

 *  Thread Starter [gabeelliott](https://wordpress.org/support/users/gabeelliott/)
 * (@gabeelliott)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/google-analytics-tracking-9/#post-8240585)
 * I’ve just added a plugin which allows me to track Google Analytic events by using
   an element class or ID. Where is the class or ID for the submit button?
 *  Plugin Author [Nick Ciske](https://wordpress.org/support/users/nickciske/)
 * (@nickciske)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/google-analytics-tracking-9/#post-8240976)
 * `<input type="submit" name="w2lsubmit" class="w2linput submit" value="Submit"
   >`
 *  [fausttiger](https://wordpress.org/support/users/fausttiger/)
 * (@fausttiger)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/google-analytics-tracking-9/#post-8536860)
 * Nick, is there a way to track the submit button click, in google analytics, built
   into our Salesforce CRM plugin? (same as gaeelliott, no landing page for form
   to track as page, so must use submit)
 * or if we need to use the secondary plugin as gabeelliott did…
 * …Any recommended plugins to use to capture the class that don’t clash with your
   SalesForce CMR?
 * Not sure what gabeelliott used.
 * Tony
 *  [fausttiger](https://wordpress.org/support/users/fausttiger/)
 * (@fausttiger)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/google-analytics-tracking-9/#post-8540887)
 * Or is Google Tag Manager the way to capture the Form Submit in your SalesForce
   plugin ?
 *  Plugin Author [Nick Ciske](https://wordpress.org/support/users/nickciske/)
 * (@nickciske)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/google-analytics-tracking-9/#post-8548817)
 * It’s a general form submit — nothing special, you can use Google Tag Manager,
   a jQuery click handler, or a vanilla JS event handler to fire a GA event.
 * Or you can use the thank you page to fire the event.
    -  This reply was modified 9 years, 6 months ago by [Nick Ciske](https://wordpress.org/support/users/nickciske/).
 *  [fausttiger](https://wordpress.org/support/users/fausttiger/)
 * (@fausttiger)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/google-analytics-tracking-9/#post-8549012)
 * The WordPress-to-lead for Salesforce CRM plugin is being used to create the form…
   and there is not always a Thank You page depending on placement of Plugin (and
   setup, need to check with our designer managing site)…
 * On one site, with dedicated Contact Us page and your form in main body… it does
   go to a thank you page… but on another site with your plugin form embedded in
   the side bar it just displays “Success!” where the form used to be.
 * Ideally, we’d like a Successful form submit… as if they mistype an email field
   or don’t fallout a required field, they have to correct and resubmit.
 * Haven’t enabled Google Tag Manager yet, was looking to keep management all in
   Google Analytics instead of GA and Tag.
 * Your form is one of our primary Submits we want to capture, but would also capture
   some other Submits (such as Comment Blog Post submit).bey and
 *  [fausttiger](https://wordpress.org/support/users/fausttiger/)
 * (@fausttiger)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/google-analytics-tracking-9/#post-8623097)
 * > It’s a general form submit — nothing special, you can use Google Tag Manager,
   > a jQuery click handler, or a vanilla JS event handler to fire a GA event.
   > Or you can use the thank you page to fire the event.
 * Nick, sorry but can you give more details or a link around the “JQuery click 
   handler or vanilla JS event hander to fire a GA event” ? What are we capturing
   in your plugin action(s)?
 * (no Thank You page, just success message… and aren’t using Google Tag Manager
   for anything currently)
 * Thanks,
 *  Plugin Author [Nick Ciske](https://wordpress.org/support/users/nickciske/)
 * (@nickciske)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/google-analytics-tracking-9/#post-8623190)
 * You can hook into the onsubmit event, or if you want to inject JS code into the
   success message, check out the `salesforce_w2l_success_message` filter on other
   notes.
 * [https://wordpress.org/plugins/salesforce-wordpress-to-lead/other_notes/](https://wordpress.org/plugins/salesforce-wordpress-to-lead/other_notes/)
 * Adding a form option for this is on the wishlist…
 *  [fausttiger](https://wordpress.org/support/users/fausttiger/)
 * (@fausttiger)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/google-analytics-tracking-9/#post-8623296)
 * Is there a tradeoff between onSubmit or JS Code (like the next page starting 
   to render and cancelling) ?
 * For JS, did you mean something like below?
 * with ga(‘send’,’event’,’eventCategory’,’eventAction’,’eventLabel’
 * added to the success message filter function?
 * —
    Salesforce_w2l_success_message_{Form ID}
 * Allows you to filter the contents of the success message before it is output 
   to dynamically populate it with a value, auto set it based on another value, 
   etc.
 * Examples:
 * // Filter Success Message on a specific form
    // salesforce_w2l_success_message_{
   Form ID} add_filter( ‘salesforce_w2l_success_message_1_tester’, ‘salesforce_w2l_success_message_1_tester_example’,
   10, 1 ); function salesforce_w2l_success_message_1_tester_example( $success ){
 *  ga(‘send’,’event’,’eventCategory’,’eventAction’,’eventLabel’)
 *  return ‘Success’;
    }
 *  Plugin Author [Nick Ciske](https://wordpress.org/support/users/nickciske/)
 * (@nickciske)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/google-analytics-tracking-9/#post-8623437)
 * Nope, that won’t work — you can’t execute JS inside a filter 😉
 * Try this:
 *     ```
       // Filter Success Message on a specific form
       // salesforce_w2l_success_message_{Form ID}
   
       add_filter( 'salesforce_w2l_success_message_1', 'salesforce_w2l_success_message_1_ga', 10, 1 );
   
       function salesforce_w2l_success_message_1_ga( $success ){
   
            $ga = '<script>ga('send','event','eventCategory','eventAction','eventLabel');</script>';
   
       return $success . $ga;
       }
       ```
   
 *  [fausttiger](https://wordpress.org/support/users/fausttiger/)
 * (@fausttiger)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/google-analytics-tracking-9/#post-8649498)
 * Thanks…
 * in hindsight, I think we should use the add_action method, since it shouldn’t
   be dependent on whether someone has enabled the Message vs landing page for a
   form. The add_filter wouldn’t work if Success message was turned off.
 *  Plugin Author [Nick Ciske](https://wordpress.org/support/users/nickciske/)
 * (@nickciske)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/google-analytics-tracking-9/#post-8649510)
 * If you’re using a landing page, you can just put the code on that page… this 
   was a solution _for those using a success message_… not a landing page.
 * > Im not using a thank you page redirect on completion of form so need to set
   > it up as an event on the button click.
 * But you jumped on someone else’s thread, so that can happen 😉
 *  [fausttiger](https://wordpress.org/support/users/fausttiger/)
 * (@fausttiger)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/google-analytics-tracking-9/#post-8649519)
 * Sorry… Wasn’t try to jump on someone else’s thread, but thought gabeelliott was
   also asking about Google Analytics tracking on your SalesForce plugin…. so thought
   I was contributing to options.
 * the thought on an action vs filter or landing page, was that capturing the submit
   action/event would work no matter what message or landing page option was selected
   later by another admin user. Or so I thought.
 *  Plugin Author [Nick Ciske](https://wordpress.org/support/users/nickciske/)
 * (@nickciske)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/google-analytics-tracking-9/#post-8649531)
 * Correct, an sf_after_sbumit action would work for both. I’ll add it to the wishlist
   😉

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

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

 * ![](https://ps.w.org/salesforce-wordpress-to-lead/assets/icon-256x256.png?rev
   =2316786)
 * [Brilliant Web-to-Lead for Salesforce](https://wordpress.org/plugins/salesforce-wordpress-to-lead/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/salesforce-wordpress-to-lead/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/salesforce-wordpress-to-lead/)
 * [Active Topics](https://wordpress.org/support/plugin/salesforce-wordpress-to-lead/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/salesforce-wordpress-to-lead/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/salesforce-wordpress-to-lead/reviews/)

 * 14 replies
 * 3 participants
 * Last reply from: [Nick Ciske](https://wordpress.org/support/users/nickciske/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/google-analytics-tracking-9/#post-8649531)
 * Status: resolved