Created
February 28, 2014 18:35
-
-
Save altadisa/9276910 to your computer and use it in GitHub Desktop.
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
# layouts/application.html.erb | |
<head> | |
<title><%= yield_or_default(:title) -%></title> | |
<meta name="description" content="<%= yield_or_default(:meta_desc) -%>"> | |
<meta name="keywords" content="<%= yield_or_default(:meta_keywords) -%>"> | |
<meta name="robots" content="<%= yield_or_default(:robots) -%>"> | |
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> | |
<%= javascript_include_tag "application", "data-turbolinks-track" => true %> | |
<%= render partial: 'layouts/partials/ga' -%> | |
<%= csrf_meta_tags %> | |
</head> | |
# layouts/partials/_ga.html.erb | |
<% unless Rails.env.test? -%> | |
<script type="text/javascript"> | |
var _gaq = _gaq || []; | |
_gaq.push(['_setAccount', '<%= "#{PRIVATE_DATA['ga_tracker']}" -%>']); | |
_gaq.push(['_setDomainName','<%= "#{PRIVATE_DATA['ga_tracker_domain']}" -%>']); | |
(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); | |
})(); | |
if (((_ref = window.history) != null ? _ref.pushState : void 0) && window.history.replaceState && typeof Turbolinks !== 'undefined') { | |
document.addEventListener('page:change', function() { | |
if (window._gaq != null) { | |
_gaq.push(['_trackPageview']); | |
} else if (window.pageTracker != null) { | |
pageTracker._trackPageview(); | |
} }) | |
} else { | |
_gaq.push(['_trackPageview']); | |
} | |
</script> | |
<% end -%> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment