mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 08:23:37 +08:00
Merge pull request #1863 from ecuk/analytics
Google Universal Analytics
This commit is contained in:
commit
88e1fadd0f
|
@ -12,4 +12,11 @@ Discourse.addInitializer(function() {
|
|||
window._gaq.push(['_trackPageview']);
|
||||
});
|
||||
}
|
||||
|
||||
// Also use Universal Analytics if it is present
|
||||
if (typeof window.ga !== 'undefined') {
|
||||
pageTracker.on('change', function() {
|
||||
window.ga('send', 'pageview');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
module CommonHelper
|
||||
def render_google_universal_analytics_code
|
||||
if Rails.env == "production" && SiteSetting.ga_universal_tracking_code.present?
|
||||
render partial: "common/google_universal_analytics"
|
||||
end
|
||||
end
|
||||
|
||||
def render_google_analytics_code
|
||||
if Rails.env == "production" && SiteSetting.ga_tracking_code.present?
|
||||
render partial: "common/google_analytics"
|
||||
|
|
10
app/views/common/_google_universal_analytics.html.erb
Normal file
10
app/views/common/_google_universal_analytics.html.erb
Normal file
|
@ -0,0 +1,10 @@
|
|||
<script>
|
||||
(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', '<%= SiteSetting.ga_universal_tracking_code %>', '<% SiteSetting.ga_universal_domain_name.gsub(/^http(s)?:\/\//, '') %>'');
|
||||
ga('send', 'pageview');
|
||||
|
||||
</script>
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
<%= raw SiteContent.content_for(:head) %>
|
||||
|
||||
<%= render_google_universal_analytics_code %>
|
||||
|
||||
<%= yield :head %>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -604,8 +604,10 @@ en:
|
|||
traditional_markdown_linebreaks: "Use traditional linebreaks in Markdown, which require two trailing spaces for a linebreak"
|
||||
post_undo_action_window_mins: "Number of seconds users are allowed to reverse actions on a post (like, flag, etc)"
|
||||
must_approve_users: "Admins must approve all users before they gain access"
|
||||
ga_tracking_code: "Google analytics tracking code code, eg: UA-12345678-9; see http://google.com/analytics"
|
||||
ga_domain_name: "Google analytics domain name, eg: mysite.com; see http://google.com/analytics"
|
||||
ga_tracking_code: "Google analytics (ga.js) tracking code code, eg: UA-12345678-9; see http://google.com/analytics"
|
||||
ga_domain_name: "Google analytics (ga.js) domain name, eg: mysite.com; see http://google.com/analytics"
|
||||
ga_universal_tracking_code: "Google Universal Analytics (analytics.js) tracking code code, eg: UA-12345678-9; see http://google.com/analytics"
|
||||
ga_universal_domain_name: "Google Universal Analytics (analytics.js) domain name, eg: mysite.com; see http://google.com/analytics"
|
||||
enable_escaped_fragments: "Enable workaround solution to help older search engine webcrawlers index your site. WARNING: enable only if you have to."
|
||||
enable_noscript_support: "Enable standard webcrawler search engine support via the noscript tag"
|
||||
top_menu: "Determine which items appear in the homepage navigation, and in what order. Example latest|new|unread|starred|categories|top|read|posted"
|
||||
|
|
|
@ -30,6 +30,12 @@ basic:
|
|||
ga_domain_name:
|
||||
client: true
|
||||
default: ''
|
||||
ga_universal_tracking_code:
|
||||
client: true
|
||||
default: ''
|
||||
ga_universal_domain_name:
|
||||
client: true
|
||||
default: 'auto'
|
||||
category_featured_topics:
|
||||
client: true
|
||||
default: 3
|
||||
|
|
Loading…
Reference in New Issue
Block a user