Skip to content

Commit

Permalink
Merge pull request #95 from saschwarz/gaflags_fix
Browse files Browse the repository at this point in the history
GA flags with incorrect tags
  • Loading branch information
jcassee committed May 27, 2016
2 parents f869323 + d579ec2 commit 9cf5c49
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions analytical/templatetags/google_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
"'%(value)s', %(scope)s]);"
SITE_SPEED_CODE = "_gaq.push(['_trackPageLoadTime']);"
ANONYMIZE_IP_CODE = "_gaq.push (['_gat._anonymizeIp']);"
SAMPLE_RATE_CODE = "_gaq.push (['_gat._setSampleRate', '%s']);"
SITE_SPEED_SAMPLE_RATE_CODE = "_gaq.push (['_gat._setSiteSpeedSampleRate', '%s']);"
SESSION_COOKIE_TIMEOUT_CODE = "_gaq.push (['_gat._setSessionCookieTimeout', '%s']);"
VISITOR_COOKIE_TIMEOUT_CODE = "_gaq.push (['_gat._setVisitorCookieTimeout', '%s']);"
SAMPLE_RATE_CODE = "_gaq.push (['_setSampleRate', '%s']);"
SITE_SPEED_SAMPLE_RATE_CODE = "_gaq.push (['_setSiteSpeedSampleRate', '%s']);"
SESSION_COOKIE_TIMEOUT_CODE = "_gaq.push (['_setSessionCookieTimeout', '%s']);"
VISITOR_COOKIE_TIMEOUT_CODE = "_gaq.push (['_setVisitorCookieTimeout', '%s']);"
DEFAULT_SOURCE = ("'https://ssl' : 'http://www'", "'.google-analytics.com/ga.js'")
DISPLAY_ADVERTISING_SOURCE = ("'https://' : 'http://'", "'stats.g.doubleclick.net/dc.js'")

Expand Down
16 changes: 8 additions & 8 deletions analytical/tests/test_tag_google_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ def test_anonymize_ip_not_present(self):
@override_settings(GOOGLE_ANALYTICS_SAMPLE_RATE=0.0)
def test_set_sample_rate_min(self):
r = GoogleAnalyticsNode().render(Context())
self.assertTrue("_gaq.push (['_gat._setSampleRate', '0.00']);" in r, r)
self.assertTrue("_gaq.push (['_setSampleRate', '0.00']);" in r, r)

@override_settings(GOOGLE_ANALYTICS_SAMPLE_RATE='100.00')
def test_set_sample_rate_max(self):
r = GoogleAnalyticsNode().render(Context())
self.assertTrue("_gaq.push (['_gat._setSampleRate', '100.00']);" in r, r)
self.assertTrue("_gaq.push (['_setSampleRate', '100.00']);" in r, r)

@override_settings(GOOGLE_ANALYTICS_SAMPLE_RATE=-1)
def test_exception_whenset_sample_rate_too_small(self):
Expand All @@ -129,12 +129,12 @@ def test_exception_when_set_sample_rate_too_large(self):
@override_settings(GOOGLE_ANALYTICS_SITE_SPEED_SAMPLE_RATE=0.0)
def test_set_site_speed_sample_rate_min(self):
r = GoogleAnalyticsNode().render(Context())
self.assertTrue("_gaq.push (['_gat._setSiteSpeedSampleRate', '0.00']);" in r, r)
self.assertTrue("_gaq.push (['_setSiteSpeedSampleRate', '0.00']);" in r, r)

@override_settings(GOOGLE_ANALYTICS_SITE_SPEED_SAMPLE_RATE='100.00')
def test_set_site_speed_sample_rate_max(self):
r = GoogleAnalyticsNode().render(Context())
self.assertTrue("_gaq.push (['_gat._setSiteSpeedSampleRate', '100.00']);" in r, r)
self.assertTrue("_gaq.push (['_setSiteSpeedSampleRate', '100.00']);" in r, r)

@override_settings(GOOGLE_ANALYTICS_SITE_SPEED_SAMPLE_RATE=-1)
def test_exception_whenset_site_speed_sample_rate_too_small(self):
Expand All @@ -151,12 +151,12 @@ def test_exception_when_set_site_speed_sample_rate_too_large(self):
@override_settings(GOOGLE_ANALYTICS_SESSION_COOKIE_TIMEOUT=0)
def test_set_session_cookie_timeout_min(self):
r = GoogleAnalyticsNode().render(Context())
self.assertTrue("_gaq.push (['_gat._setSessionCookieTimeout', '0']);" in r, r)
self.assertTrue("_gaq.push (['_setSessionCookieTimeout', '0']);" in r, r)

@override_settings(GOOGLE_ANALYTICS_SESSION_COOKIE_TIMEOUT='10000')
def test_set_session_cookie_timeout_as_string(self):
r = GoogleAnalyticsNode().render(Context())
self.assertTrue("_gaq.push (['_gat._setSessionCookieTimeout', '10000']);" in r, r)
self.assertTrue("_gaq.push (['_setSessionCookieTimeout', '10000']);" in r, r)

@override_settings(GOOGLE_ANALYTICS_SESSION_COOKIE_TIMEOUT=-1)
def test_exception_when_set_session_cookie_timeout_too_small(self):
Expand All @@ -167,12 +167,12 @@ def test_exception_when_set_session_cookie_timeout_too_small(self):
@override_settings(GOOGLE_ANALYTICS_VISITOR_COOKIE_TIMEOUT=0)
def test_set_visitor_cookie_timeout_min(self):
r = GoogleAnalyticsNode().render(Context())
self.assertTrue("_gaq.push (['_gat._setVisitorCookieTimeout', '0']);" in r, r)
self.assertTrue("_gaq.push (['_setVisitorCookieTimeout', '0']);" in r, r)

@override_settings(GOOGLE_ANALYTICS_VISITOR_COOKIE_TIMEOUT='10000')
def test_set_visitor_cookie_timeout_as_string(self):
r = GoogleAnalyticsNode().render(Context())
self.assertTrue("_gaq.push (['_gat._setVisitorCookieTimeout', '10000']);" in r, r)
self.assertTrue("_gaq.push (['_setVisitorCookieTimeout', '10000']);" in r, r)

@override_settings(GOOGLE_ANALYTICS_VISITOR_COOKIE_TIMEOUT=-1)
def test_exception_when_set_visitor_cookie_timeout_too_small(self):
Expand Down

0 comments on commit 9cf5c49

Please sign in to comment.