This repository has been archived by the owner on Dec 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move over to using the Universal Analytics snippet
Deprecate the old classic GA snippet in favor of using the universal snippet. The new universal snippet also contains commented out features such as display features and enhanced link attribution. The snippet has been tested against a website that pulled in 400 million page views over the course of a month, it also had custom event tracking implemented. Snippet provided courtesy of @rmarescu, which originated here: reed/turbolinks-compatibility#41
- Loading branch information
Showing
4 changed files
with
22 additions
and
20 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
34 changes: 21 additions & 13 deletions
34
lib/orats/templates/includes/new/rails/app/views/layouts/_google_analytics_snippet.html.erb
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 |
---|---|---|
@@ -1,13 +1,21 @@ | ||
<script type="text/javascript"> | ||
var _gaq = _gaq || []; | ||
<% if ENV['GOOGLE_ANALYTICS_UA'].present? %> | ||
_gaq.push(['_setAccount', '<%= ENV["GOOGLE_ANALYTICS_UA"] %>']); | ||
(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); | ||
})(); | ||
<% end %> | ||
<% if ENV['GOOGLE_ANALYTICS_UA'].present? %> | ||
<script data-turbolinks-eval="false"> | ||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | ||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | ||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | ||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); | ||
|
||
ga('create', '<%= ENV["GOOGLE_ANALYTICS_UA"] %>', 'auto'); | ||
</script> | ||
|
||
<script> | ||
// Enable 'Demographics and interest reports' in your analytics settings | ||
// ga('require', 'displayfeatures'); | ||
|
||
// Enable 'Use enhanced link attribution' in your analytics settings | ||
// ga('require', 'linkid', 'linkid.js'); | ||
|
||
ga('set', 'location', location.href.split('#')[0]); | ||
ga('send', 'pageview', { 'title': document.title }); | ||
</script> | ||
<% end %> |
4 changes: 0 additions & 4 deletions
4
lib/orats/templates/includes/new/rails/app/views/layouts/_google_analytics_tracker.html.erb
This file was deleted.
Oops, something went wrong.
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