Solved

javascript custom events tracking code

Posted on 2015-02-24
2
83 Views
Last Modified: 2015-08-20
hey everybody I need some help with tuning GA events tracking code. I need to track OutboundLink clicks and pass data to GA. It is a directory page of books and I need to pass book category as Event Cat, book publisher as Event Action and link as Event label. How can I get this information to pass it to GA?
0
Comment
Question by:webdirexion
  • 2
2 Comments
 
LVL 26

Accepted Solution

by:
EddieShipman earned 500 total points
ID: 40763582
I'm using GA Universal and track all of my outbond links using this function:
var trackOutboundLink = function (url) {
    ga('send', 'event', 'Outbound Links', 'click', url, {
        'hitCallback':
          function () {
              document.location = url;
          }
    });
}

Open in new window


Of course, on all my outbound anchors I have onclick attributes:
<a href="http://www.mywebsite.com" onclick="trackOutboundLink('http://www.mywebsite.com'); return false;" target="_blank">Track This Outbound Link</a>

Open in new window


You change the parameters in the ga() function call to record different things.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 40857075
@webdirexion

Have you tried the code I posted?
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now