Skip to content

Commit

Permalink
Add some more ancillilary info
Browse files Browse the repository at this point in the history
  • Loading branch information
treffynnon committed Jul 13, 2015
1 parent 2b92604 commit 8a77cd5
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 4 deletions.
2 changes: 1 addition & 1 deletion _includes/foot.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
SQL style guide
</span> by
<a xmlns:cc="http://creativecommons.org/ns#"
href="https://www.simonholywell.com"
href="https://www.simonholywell.com/?utm_source=sqlstyle.guide&utm_medium=link&utm_campaign=footer-licence"
property="cc:attributionName"
rel="cc:attributionURL">
Simon Holywell
Expand Down
2 changes: 1 addition & 1 deletion _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="wrap">
<h1 itemprop="name">SQL Style Guide</h1>
<p class="author" itemprop="author">by
<a href="https://www.simonholywell.com" itemprop="url"><span itemprop="name">Simon Holywell</span></a> &middot;
<a href="https://www.simonholywell.com/?utm_source=sqlstyle.guide&utm_medium=link&utm_campaign=header" itemprop="url"><span itemprop="name">Simon Holywell</span></a> &middot;
<a href="https://twitter.com/treffynnon">@Treffynnon</a>
</p>
<p class="twitter"><a href="https://twitter.com/share" class="twitter-share-button" data-url="{{ site.url }}" data-text="SQL style guide by @treffynnon: {{ site.description }}" data-size="large" data-dnt="true">Tweet</a>
Expand Down
2 changes: 1 addition & 1 deletion _includes/sqlstyle.guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ ZEROFILL
ZONE
```

[simon]: https://www.simonholywell.com/
[simon]: https://www.simonholywell.com/?utm_source=sqlstyle.guide&utm_medium=link&utm_campaign=md-document
"SimonHolywell.com"
[issue]: https://github.com/treffynnon/sqlstyle.guide/issues
"SQL style guide issues on GitHub"
Expand Down
54 changes: 53 additions & 1 deletion scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,56 @@ $(document).ready(function(){
window.location.hash = target;
});
});
});
});

// http://exisweb.net/link-tracking-universal-analytics
(function trackOutbounds() {
var hitCallbackHandler = function(url,win) {
if (win) {
window.open(url, win);
} else {
window.location.href = url;
}
};

var addEvent = function(el, eventName, handler) {

if (el.addEventListener) {
el.addEventListener(eventName, handler);
} else {
el.attachEvent('on' + eventName, function(){
handler.call(el);
});
}
};

if (document.getElementsByTagName) {
var el = document.getElementsByTagName('a');
var getDomain = document.domain.split('.').reverse()[1] + '.' + document.domain.split('.').reverse()[0];

// Look thru each a element
for (var i=0; i < el.length;i++) {

// Extract it's href attribute
var href = (typeof(el[i].getAttribute('href')) == 'string' ) ? el[i].getAttribute('href') : '';

// Query the href for the top level domain (xxxxx.com)
var myDomain = href.match(getDomain);

// If link is outbound and is not to this domain
if ((href.match(/^(https?:|\/\/)/i) && !myDomain) || href.match(/^mailto\:/i)) {

// Add an event to click
addEvent(el[i],'click', function(e) {
var url = this.getAttribute('href'), win = (typeof(this.getAttribute('target')) == 'string') ? this.getAttribute('target') : '';
// Log even to Analytics, once done, go to the link
ga('send', 'event', 'outbound', 'click', url,
{'hitCallback': hitCallbackHandler(url,win)},
{'nonInteraction': 1}
);
e.preventDefault();
});
}
}
}
})();

0 comments on commit 8a77cd5

Please sign in to comment.