File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed
Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,21 @@ haml example:
7171``` haml
7272= tracking_code(:account => 'UA-12345-6', :tracker_methods => tracker_methods)
7373```
74+ ### Other Tracking URLs
75+
76+ You can use other Tracking URLs with the option tracker_url and ssl_tracker_url.
77+
78+ erb example:
79+
80+ ``` erb
81+ <%= tracking_code(:account => 'UA-12345-6', :tracker_url: 'stats.g.doubleclick.net/dc.js', ssl_tracker_url: 'stats.g.doubleclick.net/dc.js') %>
82+ ```
83+
84+ haml example:
85+
86+ ``` haml
87+ = tracking_code(:account => 'UA-12345-6', :tracker_url: 'stats.g.doubleclick.net/dc.js', ssl_tracker_url: 'stats.g.doubleclick.net/dc.js')
88+ ```
7489
7590## Development
7691
Original file line number Diff line number Diff line change @@ -5,8 +5,13 @@ module Analytics
55 def tracking_code ( options = { } )
66 # needs more options: http://code.google.com/apis/analytics/docs/gaJS/gaJSApi.html
77 account = options . delete ( :account )
8+ tracker_url = options . delete ( :tracker_url )
9+ ssl_tracker_url = options . delete ( :ssl_tracker_url )
810 tracker_methods = options . delete ( :tracker_methods )
9-
11+
12+ tracker_url = 'http://' + ( tracker_url || 'www.google-analytics.com/ga.js' )
13+ ssl_tracker_url = 'https://' + ( ssl_tracker_url || 'ssl.google-analytics.com/ga.js' )
14+
1015 code = <<-EOF
1116 <script type="text/javascript">
1217 var _gaq = _gaq || [];
@@ -16,7 +21,7 @@ def tracking_code(options={})
1621 _gaq.push(['_trackPageview']);
1722 (function() {
1823 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
19- ga.src = ('https:' == document.location.protocol ? 'https://ssl ' : 'http://www') + '.google-analytics.com/ga.js' ;
24+ ga.src = ('https:' == document.location.protocol ? '#{ ssl_tracker_url } ' : '#{ tracker_url } ') ;
2025 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
2126 })();
2227 </script>
@@ -33,9 +38,9 @@ def custom_variables
3338 end
3439 arr . reverse [ 0 ..4 ] . reverse . join ( "\n " )
3540 end
36-
41+
3742 private
38-
43+
3944 def insert_tracker_methods ( tracker_methods )
4045 return nil if tracker_methods . nil?
4146 arr = [ ]
You can’t perform that action at this time.
0 commit comments