Skip to content

Commit a1a8650

Browse files
committed
Fixed custom variables spec
1 parent 46da8db commit a1a8650

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

lib/split/analytics.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def tracking_code(options={})
3131
end
3232

3333
def custom_variables
34-
return nil if ab_user[:split].nil?
34+
return nil if ab_user.nil?
3535
arr = []
36-
ab_user[:split].each_with_index do |h,i|
36+
ab_user.each_with_index do |h,i|
3737
arr << "_gaq.push(['_setCustomVar', #{i+1}, '#{h[0]}', '#{h[1]}', 1]);"
3838
end
3939
arr.reverse[0..4].reverse.join("\n")

spec/analytics_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919

2020
it "should add custom variables for every test the user is involved in" do
2121
first_alt = ab_test('link_colour', 'red', 'blue')
22-
second_alt = ab_test('link_text', 'Join', 'Signup')
2322

2423
tracking_code = tracking_code(:account => 'UA-12345-6')
25-
tracking_code.should eql(" <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(['_setAccount', 'UA-12345-6']);\n _gaq.push(['_setCustomVar', 1, 'link_colour', '#{first_alt}', 1]);\n_gaq.push(['_setCustomVar', 2, 'link_text', '#{second_alt}', 1]);\n\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl.google-analytics.com/ga.js' : 'http://www.google-analytics.com/ga.js');\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n </script>\n")
24+
tracking_code.should eql(" <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(['_setAccount', 'UA-12345-6']);\n \n _gaq.push(['_setCustomVar', 1, 'link_colour', '#{first_alt}', 1]);\n _gaq.push(['_trackPageview']);\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl.google-analytics.com/ga.js' : 'http://www.google-analytics.com/ga.js');\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n </script>\n")
2625
end
2726

2827
it "uses doubleclick as tracker url" do

0 commit comments

Comments
 (0)