Analytics
2.5K members online now
2.5K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

How Can We track Events If Multiple Buttons are there?

Follower ✭ ☆ ☆
# 1
Follower ✭ ☆ ☆

Hello All,

 

I want to track Howmany People clicks the "Call Button" In my page. If it is a single button we can track it.

But lots of call buttons in my page. How can we track? If the code is present in all pages, It would be difficult I think, Correct me If I am wrong...

This is my page https://connect.callhealth.com/Appointments/SpecialistList

 

and 

 

Could anyone tell me how would be the code for this page to track call button event https://goo.gl/QhRVvX  ?

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Mahesh A
November 2016

Re: How Can We track Events If Multiple Buttons are there?

Top Contributor
# 2
Top Contributor

Hi,

 

Your call buttons have the class "phone" and you are using jquery, you can use a simple javascript that will send an event when the element with that class attribute is clicked:

<script>
$(document).ready(function() {
	$(".phone").each(function() {
		$(this).click(function(event) {
			ga('send', 'event', 'CallButton', 'Clicked');
		});
	});
});
</script>

Hope this helps.


Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author Mahesh A
November 2016

Re: How Can We track Events If Multiple Buttons are there?

Top Contributor
# 2
Top Contributor

Hi,

 

Your call buttons have the class "phone" and you are using jquery, you can use a simple javascript that will send an event when the element with that class attribute is clicked:

<script>
$(document).ready(function() {
	$(".phone").each(function() {
		$(this).click(function(event) {
			ga('send', 'event', 'CallButton', 'Clicked');
		});
	});
});
</script>

Hope this helps.


Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

How Can We track Events If Multiple Buttons are there?

Follower ✭ ☆ ☆
# 3
Follower ✭ ☆ ☆

Thank You So much Arnold.

 

Should I use this code mix with Analytics code or should I use it separate script?

 

How Can We track Events If Multiple Buttons are there?

Top Contributor
# 4
Top Contributor

Hi,

 

This code needs the main analytics tracking script, you need to put it after the jquery library reference.

 

Let me know if you have more questions.

 


Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

How Can We track Events If Multiple Buttons are there?

Follower ✭ ☆ ☆
# 5
Follower ✭ ☆ ☆

Should I Use like this?

<script>
(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', 'https://www.google-analytics.com/analytics.js', 'ga');

ga('create', 'UA-63646674-5', 'auto');
ga('send', 'pageview');

</script>

</script>
<script>
$(document).ready(function() {
$(".phone").each(function() {
$(this).click(function(event) {
ga('send', 'event', 'CallButton', 'Clicked');
});
});
});
</script>

How Can We track Events If Multiple Buttons are there?

Follower ✭ ☆ ☆
# 6
Follower ✭ ☆ ☆
</script>
<script>
$(document).ready(function() {
$(".phone").each(function() {
$(this).click(function(event) {
ga('send', 'event', 'CallButton', 'Clicked');
});
});
});
</script>


Still Am Confusing with this tracking.

Can I have your Hangouts ID?



Regards,

Mahesh

Re: How Can We track Events If Multiple Buttons are there?

Top Contributor
# 7
Top Contributor

Hi,

 

Use it like this:

<script>
  (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','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-63646674-5', 'auto');
  ga('send', 'pageview');

</script>
<script>
$(document).ready(function() {
   $(".phone").each(function() {
      $(this).click(function(event) {
	  ga('send', 'event', 'CallButton', 'Clicked');
      });
   });
});

</script>

This should work, let me know if you was able to get it work.


Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

How Can We track Events If Multiple Buttons are there?

Follower ✭ ☆ ☆
# 8
Follower ✭ ☆ ☆

And one more doubt please...

After clicking the call button a pop up is opening and phone number is displaying right..Can we track how many people are clicking that phone number also?


Could you please tell me is that possible? 

How Can We track Events If Multiple Buttons are there?

Follower ✭ ☆ ☆
# 9
Follower ✭ ☆ ☆

Hi Arnold,

 

The below code will work I think for my question. Could you please look at this and let me know any modifications. Please


<script>
(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','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-63646674-5', 'auto');
ga('send', 'pageview');
</script>
<script> $(document).ready(function() { $(".phone").each(function() { $(this).click(function(event) { ga('send', 'event', 'CallButton', 'Clicked'); }); });
$("#strDoctorMobileno").each(function() { $(this).click(function(event) { ga('send', 'event', 'PhoneNumber', 'Clicked'); });
});
});
</script>

 

How Can We track Events If Multiple Buttons are there?

Top Contributor
# 10
Top Contributor

Hi,

 

I checked your code and I didn't find any issues.

Let me know when it's implemented and I'll check on the site.


Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital