diff --git a/analytical/templatetags/mixpanel.py b/analytical/templatetags/mixpanel.py index 8ac2f70..d590f78 100644 --- a/analytical/templatetags/mixpanel.py +++ b/analytical/templatetags/mixpanel.py @@ -16,14 +16,13 @@ from analytical.utils import is_internal_ip, disable_html, get_identity, \ MIXPANEL_API_TOKEN_RE = re.compile(r'^[0-9a-f]{32}$') TRACKING_CODE = """ """ -IDENTIFY_CODE = "mpq.push(['identify', '%s']);" -EVENT_CODE = "mpq.push(['track', '%(name)s', %(properties)s]);" +IDENTIFY_CODE = "mixpanel.register_once({distinct_id: '%s'});" +EVENT_CODE = "mixpanel.track('%(name)s', %(properties)s);" EVENT_CONTEXT_KEY = 'mixpanel_event' register = Library() diff --git a/analytical/tests/test_tag_mixpanel.py b/analytical/tests/test_tag_mixpanel.py index d7132b5..3f61485 100644 --- a/analytical/tests/test_tag_mixpanel.py +++ b/analytical/tests/test_tag_mixpanel.py @@ -20,13 +20,13 @@ class MixpanelTagTestCase(TagTestCase): def test_tag(self): r = self.render_tag('mixpanel', 'mixpanel') self.assertTrue( - "mpq.push(['init', '0123456789abcdef0123456789abcdef']);" in r, + "mixpanel.init('0123456789abcdef0123456789abcdef');" in r, r) def test_node(self): r = MixpanelNode().render(Context()) self.assertTrue( - "mpq.push(['init', '0123456789abcdef0123456789abcdef']);" in r, + "mixpanel.init('0123456789abcdef0123456789abcdef');" in r, r) @override_settings(MIXPANEL_API_TOKEN=SETTING_DELETED) @@ -44,18 +44,18 @@ class MixpanelTagTestCase(TagTestCase): @override_settings(ANALYTICAL_AUTO_IDENTIFY=True) def test_identify(self): r = MixpanelNode().render(Context({'user': User(username='test')})) - self.assertTrue("mpq.push(['identify', 'test']);" in r, r) + self.assertTrue("mixpanel.register_once({distinct_id: 'test'});" in r, r) @override_settings(ANALYTICAL_AUTO_IDENTIFY=True) def test_identify_anonymous_user(self): r = MixpanelNode().render(Context({'user': AnonymousUser()})) - self.assertFalse("mpq.push(['identify', " in r, r) + self.assertFalse("mixpanel.register_once({distinct_id:" in r, r) def test_event(self): r = MixpanelNode().render(Context({'mixpanel_event': - ('test_event', {'prop1': 'val1', 'prop2': 'val2'})})) - self.assertTrue("mpq.push(['track', 'test_event', " - '{"prop1": "val1", "prop2": "val2"}]);' in r, r) + ('test_event', {'prop1': 'val1', 'prop2': 'val2'})})) + self.assertTrue("mixpanel.track('test_event', " + '{"prop1": "val1", "prop2": "val2"});' in r, r) @override_settings(ANALYTICAL_INTERNAL_IPS=['1.1.1.1']) def test_render_internal_ip(self): diff --git a/docs/services/mixpanel.rst b/docs/services/mixpanel.rst index 70f4488..980f22f 100644 --- a/docs/services/mixpanel.rst +++ b/docs/services/mixpanel.rst @@ -124,8 +124,7 @@ notation, as described in the section titled `"Asynchronous Tracking with Javascript"`_ in the Mixpanel documentation. For example:: - mpq.push(["track", "play-game", {"level": "12", "weapon": "sword", "character": "knight"}]); + mixpanel.track("play-game", {"level": "12", "weapon": "sword", "character": "knight"}); .. _django-celery: http://github.com/winhamwr/mixpanel-celery .. _`"Asynchronous Tracking with Javascript"`: http://mixpanel.com/api/docs/guides/integration/js#async -