mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Add userId to GA tracking
This commit is contained in:
@@ -15,6 +15,15 @@ module ApplicationHelper
|
|||||||
include ConfigurableUrls
|
include ConfigurableUrls
|
||||||
include GlobalPath
|
include GlobalPath
|
||||||
|
|
||||||
|
def ga_universal_json
|
||||||
|
cookie_domain = SiteSetting.ga_universal_domain_name.gsub(/^http(s)?:\/\//, '')
|
||||||
|
result = {cookieDomain: cookie_domain}
|
||||||
|
if current_user.present?
|
||||||
|
result[:userId] = current_user.id
|
||||||
|
end
|
||||||
|
result.to_json.html_safe
|
||||||
|
end
|
||||||
|
|
||||||
def shared_session_key
|
def shared_session_key
|
||||||
if SiteSetting.long_polling_base_url != '/'.freeze && current_user
|
if SiteSetting.long_polling_base_url != '/'.freeze && current_user
|
||||||
sk = "shared_session_key"
|
sk = "shared_session_key"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
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');
|
})(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('create', '<%= SiteSetting.ga_universal_tracking_code %>', <%= ga_universal_json %>);
|
||||||
ga('send', 'pageview');
|
ga('send', 'pageview');
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user