Analytics
2.3K members online now
2.3K 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

Tracking any appeared html code

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello Everybody!

 

My question is: Can i track any appeared html on my website? For example there are six buttons with the same classes.

 

Example:

 

<a class="buy " onclick="cart.add(4,2,1,0,0,false,0);return false;">Buy</a>

<a class="buy " onclick="cart.add(3,1,1,0,0,false,0);return false;">Buy</a>

<a class="buy " onclick="cart.add(5,2,1,0,0,false,0);return false;">Buy</a>

ect...

 

I would track them one by one. Its just an example. Is there any option to track any appeared code part?

 

Thanks for teh answers.

 

Best Regards,

Peter

 

1 Expert replyverified_user

Re: Tracking any appeared html code

Top Contributor
# 2
Top Contributor
Hi Peter,

You can track the clicks as events or virtual pageviews.

Please check the article below for details about both methods:
https://www.optimizesmart.com/event-tracking-guide-google-analytics-simplified-version/

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

Re: Tracking any appeared html code

[ Edited ]
Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

I see, but if there are 6 buttons with the same text and same class, how can i differentiate them?

As You can see the onclick values are different only:

<a class="buy " onclick="cart.add(4,2,1,0,0,false,0);return false;">Buy</a>
<a class="buy " onclick="cart.add(3,1,1,0,0,false,0);return false;">Buy</a>
<a class="buy " onclick="cart.add(5,2,1,0,0,false,0);return false;">Buy</a>

Re: Tracking any appeared html code

Top Contributor
# 4
Top Contributor
You can send a different virtual pageview for each link like:

<a class="buy " onclick="cart.add(4,2,1,0,0,false,0);ga('send', 'pageview', '/virtual-page-1');return false;">Buy</a>
<a class="buy " onclick="cart.add(3,1,1,0,0,false,0);ga('send', 'pageview', '/virtual-page-2');return false;">Buy</a>
<a class="buy " onclick="cart.add(5,2,1,0,0,false,0);ga('send', 'pageview', '/virtual-page-3');return false;">Buy</a>

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

Re: Tracking any appeared html code

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
Dear Arnold!

That sounds great, but i can't reach the site code. Can i add these from GTM?

Re: Tracking any appeared html code

Top Contributor
# 6
Top Contributor
Hi Peter,

Do you have a parent element with a specific id or class for the "Buy" links?

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

Re: Tracking any appeared html code

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭
Nothing specific, all of them has the same parent elements, this is the problem. So i can only differentiate them by the onclick value.

Re: Tracking any appeared html code

Top Contributor
# 8
Top Contributor
The same parent element is fine as long the links are in the same container. We can target the links using jquery.

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

Re: Tracking any appeared html code

Visitor ✭ ✭ ✭
# 9
Visitor ✭ ✭ ✭
Yea they are in the same. Can You tell me an example? I don't know how jquery works. And how can i track by jquery?

Re: Tracking any appeared html code

Top Contributor
# 10
Top Contributor
Do you have the jquery library included on your 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