Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8771205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:43:38+00:00 2026-06-13T17:43:38+00:00

[cross-posted on Google Products Forum http://productforums.google.com/d/topic/analytics/ZrB14a-6gqI/discussion ] I am using the following code at

  • 0
[cross-posted on Google Products Forum http://productforums.google.com/d/topic/analytics/ZrB14a-6gqI/discussion ]

I am using the following code at http://www.cs.bris.ac.uk/Research/Algorithms/

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
<script type="text/javascript">
function recordOutboundLink(link, category, action) {
try {
var myTracker=_gat._getTrackerByName();
_gaq.push(['myTracker._trackEvent', category , action ]);
setTimeout('document.location = "' + link.href + '"', 100)
}catch(err){}
}
</script>

which I just copied directly from http://support.google.com/analytics/bin/answer.py?hl=en&answer=1136920 .

However, it doesn’t actually seem to report any clicks on the links where I have added onClick="recordOutboundLink(this, 'Outbound Links', 'Postdoc advert');return false;", for example. I have seen a number of complaints about this online but I haven’t found a solution that works.

What am I doing wrong?

P.S. The closest related online complaint seems to be http://productforums.google.com/forum/#!topic/analytics/4oPBJEoZ8s4 which just claims the code is broken.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:43:39+00:00Added an answer on June 13, 2026 at 5:43 pm

    Here’s what I’m using, which has been working for me. I’m using jQuery to add the onclick handler to any link with a class of “referral”, but I’d expect adding it directly in the HTML to work as well.

      $(function() {
        $('.referral').click(function() {
          _gaq.push(['_trackEvent', 'Referral', 'Click', this.href]);
          setTimeout('document.location = "' + this.href + '"', 100);
          return false;
        });
      });
    

    edit: I believe your syntax for invoking a tracker by name is wrong. Since you aren’t using a named tracker when you set up tracking at page load, you shouldn’t try to name it later either. See the documentation for _gaq.push.

    More precisely:

    1. The var myTracker declaration is unused, so you can just delete that line. Variables declared within the scope of recordOutboundLink aren’t visible when other functions, such as _gaq.push, are running, so it can’t be relevant.
    2. You should simply use '_trackEvent' instead of 'myTracker._trackEvent'.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for cross posting.The following question is also posted on Elastic Search's google group.
This is already cross-posted at MS Connect: https://connect.microsoft.com/VisualStudio/feedback/details/560451 I am attempting to override the
Cross-posted from the Cukes Google Group: I have experimented with a number of methods
This is cross-posted on the ggplot2 google group My situation is that I'm working
I cross-posted in Javaranch too. I did my due diligence by doing Google search.
Note: I've cross-posted this question in the grails-user mailing list This weekend using this
Cross posted form the codeigniter forum, where I got crickets. I’ve got a query
(cross-posted on Mozilla: http://forums.mozillazine.org/viewtopic.php?f=7&t=2254955 ) I'm trying to work with the Mozilla storageService .
I posted a problem I'm having with the FlowPlayer jQuery plugin at http://static.flowplayer.org/forum/1/29367 ,
This is cross posted from the shopify api forum- I have an app that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.