Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add includeDestination option

  • Loading branch information...
commit b87a18f814fa22aadf9ea4f8917489c4f6fe0a31 1 parent ac39dec
@ejschmitt authored
Showing with 27 additions and 3 deletions.
  1. +23 −0 README.markdown
  2. +4 −3 jquery.outbound-analytics.js
View
23 README.markdown
@@ -37,11 +37,25 @@ Advanced Usage
OutboundAnalytics contains several settings that can be changed for
better tracking, these settings are as follows:
+* includeDestination - default: true
* trackPath - default: 'outbound'
* target - default: '_blank'
* pathSuffix - default: ''
* pathSuffixAttribute - default: null
+### includeDestination
+
+includeDestination determines if the tracked page url should include the final destination url.
+
+```html
+<script>
+ $('.outbound').outboundAnalytics({includeDestination: false});
+</script>
+<a href='http://example.com' class='outbound'>Click me</a>
+
+Tracked Url: '/outbound'
+```
+
### trackPath
trackPath sets the first part of the fake url sent to GA for tracking, can be changed to something else for greater flexibility.
@@ -109,6 +123,15 @@ Tracked Url: 'outbound/bounce/custom-link/http://example.com'
Tracked Url: '/amazon/suggested/deals_index/text_link/http://example.com'
```
+```html
+<script>
+ $('.outbound').outboundAnalytics({includeDestination: false, pathSuffix: 'amazon', pathSuffixAttribute: 'data-outbound-suffix'});
+</script>
+<a href='http://example.com' class='outbound' data-outbound-suffix='suggested/deals_index/text_link'>Click me</a>
+
+Tracked Url: '/amazon/suggested/deals_index/text_link'
+```
+
Author
------
Erick Schmitt :: [@ejschmitt][0]
View
7 jquery.outbound-analytics.js
@@ -2,6 +2,7 @@
$.fn.outboundAnalytics = function(options) {
var defaults = {
+ includeDestination: true,
trackPath: 'outbound',
pathSuffix: '',
pathSuffixAttribute: null,
@@ -19,9 +20,9 @@
var gaUrl = [];
gaUrl.push(options.trackPath);
- options.pathSuffix ? gaUrl.push(options.pathSuffix) : null;
- options.pathSuffixAttribute && that.attr(options.pathSuffixAttribute) ? gaUrl.push(that.attr(options.pathSuffixAttribute)) : null;
- gaUrl.push(that.attr('href'));
+ if (options.pathSuffix) { gaUrl.push(options.pathSuffix) };
+ if (options.pathSuffixAttribute && that.attr(options.pathSuffixAttribute)) { gaUrl.push(that.attr(options.pathSuffixAttribute)) };
+ if (options.includeDestination) { gaUrl.push(that.attr('href')) };
gaUrl = gaUrl.join('/');
that.click(function(e) {
if (_gaq) {
Please sign in to comment.
Something went wrong with that request. Please try again.