Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions jquery.gaaware.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ Version: 1.8.6
// Settings
this.s = $.extend({
UA: 'UA-XXXXX-X',
dev_UA: null,
d: window.document.domain,
domains: [],
include_only: null,
exclude_subdomains: ['preview', 'dev', 'test', 'stage', 'review', 'demo', 'train'],
dev_subdomains: ['preview', 'dev', 'test', 'stage', 'review', 'demo', 'train'],
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets keep this titled exclude_subdomains because we are excluding form production data and for backwards compatibility. Also if there is no dev code we do want it to act as an exclude

asset_extentions: ['pdf', 'txt', 'csv', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'jpg', 'jpeg', 'png', 'gif', 'psd', 'ai', 'eps', 'zip', 'xml', 'json', 'avi', 'mp4', 'mp3', 'mov', 'mpeg', 'wmv', 'rtf', 'swf', 'flv', 'js', 'css', 'eot', 'svg', 'ttf', 'woff', 'otf'],
track_alt_protocols: ['mailto', 'spotify', 'ftp', 'file', 'tel'],
vpv_prefix: '/vpv',
Expand All @@ -37,6 +38,7 @@ Version: 1.8.6
debug_mode: function(message){ console.info(message); },
track: true,
no_track_class: 'ga_notrack',
auto_track_page_view: true,
custom_vars: [],
auto_social: false,
social_page_url: null,
Expand All @@ -50,12 +52,8 @@ Version: 1.8.6
// Variables
window._gaq = window._gaq || [];
this.current_domain_state = null;
this.track_multi = this.s.UA.constructor === Array ? true : false;
this.cross_domain_disabled = false;

// Process Variables
this.s.UA = this.track_multi ? this.s.UA : [this.s.UA];

// Init
this.setup();

Expand All @@ -80,19 +78,31 @@ Version: 1.8.6
}

// Exclude Sub Domains
if(this.s.exclude_subdomains) {
if(this.s.dev_subdomains) {
var domain_parts = this.s.d.split('.');
var domain_i;
for(var ex_i = 0; ex_i < this.s.exclude_subdomains.length; ex_i++) {

loop1:
for(var ex_i = 0; ex_i < this.s.dev_subdomains.length; ex_i++) {
for(domain_i = 0; domain_i < domain_parts.length; domain_i++) {
if(domain_parts[domain_i] == this.s.exclude_subdomains[ex_i]) {
if(this.s.debug) this.s.debug_mode('Tracking off: current domain contains an excluded sub domain in this.s.exclude_subdomains: '+this.s.exclude_subdomains[ex_i]);
this.s.track = false;
return;
if(domain_parts[domain_i] == this.s.dev_subdomains[ex_i]) {
if(this.s.dev_UA != null) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider just making this if(this.s.dev_UA) {

this.s.UA = this.s.dev_UA;
if(this.s.debug) this.s.debug_mode('Setting UA to dev_UA: current domain contains a dev sub domain in this.s.dev_subdomains: '+this.s.dev_subdomains[ex_i]);
break loop1;
} else {
this.s.track = false;
if(this.s.debug) this.s.debug_mode('Tracking off: current domain contains a dev sub domain in this.s.dev_subdomains: '+this.s.dev_subdomains[ex_i]);
return;
}
}
}
}
}

// Process Variables
this.track_multi = this.s.UA.constructor === Array ? true : false;
this.s.UA = this.track_multi ? this.s.UA : [this.s.UA];

// Activate Each Tracking Code
for (var i = 0; i < this.s.UA.length; i++) {
Expand Down Expand Up @@ -127,8 +137,14 @@ Version: 1.8.6
}

// Track page view for current page
window._gaq.push([pre+'_trackPageview']);
if(this.s.debug) this.s.debug_mode(this.s.UA[i]+' active!');
if(this.s.auto_track_page_view === true) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider just using if(this.s.auto_track_page_view){

window._gaq.push([pre+'_trackPageview']);
if(this.s.debug) {
this.s.debug_mode(this.s.UA[i]+' active!');
}
} else if (this.s.debug) {
this.s.debug_mode(this.s.UA[i]+' auto track disabled!');
}
}

// Default async embed code
Expand Down