# Tracking via Google analytics

**URL:** <https://forum.mautic.org/t/tracking-via-google-analytics/7235>\
**Category:** General Discussion\
**Created:** [January 20, 2017, 1:46am UTC](https://forum.mautic.org/t/tracking-via-google-analytics/7235 "2017-01-20T01:46:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mconner1](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@mconner1](https://forum.mautic.org/u/mconner1)\
**Post date:** [January 20, 2017, 1:46am UTC](https://forum.mautic.org/t/tracking-via-google-analytics/7235/1 "2017-01-20T01:46:04Z")

</div>

Hi!  
  
  
  
I’m trying to track signup clicks in google analytics to measure how well the ad network is going. I know I can track it in Mautic, but that doesn’t easily show their search query, nor ties into how well my ad spend is going.  
  
  
  
I was previously using mailchimp, and I modified their form to include an ‘onSubmit’ that called googles ga(“send”…) function. I’ve tried the same thing with the mautic form code, and ended up somewhat breaking the form. ![:(]( ":(")  
  
I then tried playing around with moving this code elsewhere in the form with no success.  
  
I know I can trigger google tracking if I redirect the form to a new page (standard include of the google tracking url), but how do I track it when the user stays on the page and gets a message?  
  
  
  
Before I go hacking away at the core code and break it terribly, I’m wondering if someone else has an easy ish solution?  
  
  
  
Thanks!

---

<div class="post-metadata">

**Author:** ![mconner1](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@mconner1](https://forum.mautic.org/u/mconner1)\
**Post date:** [January 20, 2017, 1:46am UTC](https://forum.mautic.org/t/tracking-via-google-analytics/7235/2 "2017-01-20T01:46:04Z")

</div>

Hi!

I’m trying to track signup clicks in google analytics to measure how well the ad network is going. I know I can track it in Mautic, but that doesn’t easily show their search query, nor ties into how well my ad spend is going.

I was previously using mailchimp, and I modified their form to include an ‘onSubmit’ that called googles ga(“send”…) function. I’ve tried the same thing with the mautic form code, and ended up somewhat breaking the form. ☹  
I then tried playing around with moving this code elsewhere in the form with no success.  
I know I can trigger google tracking if I redirect the form to a new page (standard include of the google tracking url), but how do I track it when the user stays on the page and gets a message?

Before I go hacking away at the core code and break it terribly, I’m wondering if someone else has an easy ish solution?

Thanks!

---

<div class="post-metadata">

**Author:** ![mconner1](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@mconner1](https://forum.mautic.org/u/mconner1)\
**Post date:** [January 25, 2017, 1:33am UTC](https://forum.mautic.org/t/tracking-via-google-analytics/7235/3 "2017-01-25T01:33:12Z")

</div>

Finally solved it…

By using onClick instead of onSubmit. So in the html of the form, you’ll see something like:

Yes, Click Here!

Add in the onclick code calling the ga event:

Yes, Click Here!

Anyone know if there’s a way (or a plan) to have that in the mautic interface, rather than editing the html?

---

<div class="post-metadata">

**Author:** ![Ghar](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@Ghar](https://forum.mautic.org/u/Ghar)\
**Post date:** [March 12, 2017, 1:30am UTC](https://forum.mautic.org/t/tracking-via-google-analytics/7235/4 "2017-03-12T01:30:49Z")

</div>

This worked great - thanks
