forked from reddit-archive/reddit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clicks on listing links to be tracked via google-analytics End users may disable google analytics to opt-out of tracking
- Loading branch information
Showing
7 changed files
with
67 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* Analytics, such as event tracking for google analytics */ | ||
$(function() { | ||
|
||
function recordOutboundLink(link) { | ||
/* category/action/label are essentially "tags" used by | ||
google analytics */ | ||
var category = "outbound link"; | ||
var action = link.attr("domain"); | ||
var label = link.attr("srcurl") || link.attr("href"); | ||
|
||
/* Find the parent link <div> for info on promoted/self/etc */ | ||
var link_entry = link.thing(); | ||
|
||
if (link_entry.hasClass("selflink")){ | ||
category = "internal link"; | ||
} | ||
|
||
if (link_entry.hasClass("promotedlink")){ | ||
category += " promoted"; | ||
} | ||
|
||
_gaq.push(['_trackEvent', category, action, label]); | ||
} | ||
|
||
$("body").delegate("div.link .entry .title a.title, div.link a.thumbnail", | ||
"mouseup", function(e) { | ||
switch (e.which){ | ||
/* Record left and middle clicks */ | ||
case 1: | ||
/* CAUTION - left click case falls through to middle click */ | ||
case 2: | ||
recordOutboundLink($(this)); | ||
break; | ||
default: | ||
/* right-clicks and non-standard clicks ignored; no way to | ||
know if context menu is used to pull up new tab or not */ | ||
break; | ||
} | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters