Analytics
5.6K members online now
5.6K 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 to make an event of the new Google Partners Badge click...?

Follower ✭ ☆ ☆
# 1
Follower ✭ ☆ ☆

Hi everyone Smiley Happy

We have new beautiful javascript Google Partners badge to use on our websites. How do I modify the code so that clicking the Badge on my website fires an event in Analytics...?

1 Expert replyverified_user

How to make an event of the new Google Partners Badge click...?

Top Contributor
# 2
Top Contributor

I'm assuming you are not able/permitted to edit the badge code?

Are you able to wrap it in a span tag and then apply an onclick to the span to trigger the event
eg  <span onclick="ga('send', 'event', 'Partner Badge', 'clicked');">other badge code here</span>

Alternatively GA Autotrack might be helpful in tracking it as an event eg a click on the badge.. or as an outbound link, if it links to a page on an external site

https://github.com/googleanalytics/autotrack

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

Re: How to make an event of the new Google Partners Badge click...?

Follower ✭ ☆ ☆
# 3
Follower ✭ ☆ ☆

I am able to edit the code, but I'm not sure if I know how to make the change Smiley Happy

Should the code look like this:

<span onclick="ga('send', 'event', 'Partner Badge', 'clicked');">
<script src="https://apis.google.com/js/platform.js" async defer></script>
<div class="g-partnersbadge" data-agency-id="3355832644"></div>
</span>

...? It looks like I made a mistake, as it doesn't fire any event Smiley Sad

Marked as Best Answer.
Solution
Accepted by topic author Kasia I
March 2017

How to make an event of the new Google Partners Badge click...?

Top Contributor
# 4
Top Contributor

Thanks @Kasia I :-)
are you able to provide a link to the page that has the badge code on it?
Id like to have a look at what the code is doing/rendering in the page.
I have a feeling it is possibly inserting the badge via an iframe or something inwhich

case, it may not be possible to track it or may have to go about it a different way

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here