Analytics
3.1K members online now
3.1K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Button Tracking Code

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello,

 I am unable to see the event of button clicking in Universal Analytics.

I am a newbie here and not using GTM( Afraid of debugging and codes). 

The code that I am using is :

<a href=”Sign UP” onClick=” ga('send', 'event', 'Sign up', 'Subscribe', 'Newsletter Sign Up');”> Sign Up </a>

<a href=”Click on Submit” onClick=” ga('send', 'event', 'Sign up', 'Submit', 'MAP');”> Click on Submit </a>

What is wrong with the code? These buttons link to third party domain, so I just want to counts the clicks on the button. Any help will be greatly appreciated.

 

Thanks!

1 Expert replyverified_user

Re: Button Tracking Code

A T
Participant ✭ ✭ ✭
# 2
A T
Participant ✭ ✭ ✭

You can easily debug on the website with GA debugger:
https://chrome.google.com/webstore/detail/jnkmfdileelhofjcijamephohjechhna

You can check in chrome, console tab with 'Preserve log' turned ON.

Re: Button Tracking Code

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
This does not help me much. I would really appreciate if u can comment on my code like in other post people have written the write codes!

Re: Button Tracking Code

A T
Participant ✭ ✭ ✭
# 4
A T
Participant ✭ ✭ ✭

Code looks correct.

 

Can you share the page url where we can see the code?

Re: Button Tracking Code

Explorer ✭ ✭ ☆
# 5
Explorer ✭ ✭ ☆
Hi Swati,

Try using the below code:

<a href=”Sign UP” onClick=” ga(‘send’, ‘event’, ‘Sign up’, ‘Subscribe’, ‘Newsletter Sign Up’);”> Sign Up </a>
<a href=”Click on Submit” onClick=” ga(‘send‘,‘event‘,‘Sign up‘,‘Submit‘,‘MAP‘);”> Click on Submit </a>

It should work.

Sam

Re: Button Tracking Code

Participant ✭ ✭ ☆
# 6
Participant ✭ ✭ ☆
Maybe you have classic Google Analytics tracking code on your website but for event tracking you are using Universal Analytics syntax.
How looks like tracking code on your website?

Re: Button Tracking Code

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭
Hello Tomas,

It is universal analytic, I have the tracking code and one more event- clicking on a button works fine. But the code for this two button/clicks does not record anything. These two lead to third party links. The website is in squarespace and the newsletter is a block.

Thanks!

Re: Button Tracking Code

Visitor ✭ ✭ ✭
# 8
Visitor ✭ ✭ ✭
Hello Sam,

Thanks for your response!

The code is the same as I tried before. No luck!

Thanks,
Swati

Re: Button Tracking Code

Participant ✭ ✭ ☆
# 9
Participant ✭ ✭ ☆
Can you insert exactly the code you have on website? Or maybe you can provide a website URL?

Re: Button Tracking Code

[ Edited ]
Visitor ✭ ✭ ✭
# 10
Visitor ✭ ✭ ✭

&lt;script&gt;
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXX', 'auto');
ga('send', 'pageview');
ga('send', 'event', 'Videos', 'Play', 'https://youtu.beXXXXXX')
<a href=”Buy On Amazon” onClick=” ga('send', 'event', 'Button', 'Click', 'Click on- Buy on Amazon');”> Buy On Amazon </a>

// CODE THAT IS NOT RECORDING IN UA. EVERYTHING ON TOP WORKS FINE


<a href=”Sign UP” onSubmit=” ga('send', 'event', 'Sign up', 'Subscribe', 'Newsletter Sign Up');”> Sign Up </a>

<a href=”Mom Ambassador Submit Button” onClick=” ga('send', 'event', 'Button', 'Click', 'Mom Ambassador Submit Button');”> Mom Ambassador Submit Button </a>
<a href=”Sign UP” onClick=” ga(‘send’, ‘event’, ‘Sign up’, ‘Subscribe’, ‘Newsletter Sign Up’);”> Sign Up </a>
<a href=”Click on Submit” onClick=” ga(‘send‘,‘event‘,‘Sign up‘,‘Submit‘,‘Mom Ambassador Submit Button‘);”> Click on Submit </a>


&lt;/script&gt;
</head>