jazzband / django-analytical

Analytics services for Django projects
MIT License
1.2k stars 169 forks source link

basic mixpanel tracking #224

Open serenamm opened 2 years ago

serenamm commented 2 years ago

Hi!

Thanks so much for creating this repo. I'm having trouble doing basic mixpanel tracking.

I've set up my template html file to look like this:

{% load analytical %}
{% load mixpanel %}
<!DOCTYPE ... >
<html>
    <head>
        {% analytical_head_top %}

        ...

        {% analytical_head_bottom %}
    {% mixpanel %}
    </head>
    <body>
        {% analytical_body_top %}

        ...

        {% analytical_body_bottom %}
    </body>
</html>

and my settings.py file looks like:

INSTALLED_APPS = [
    ...
    'analytical',
    ...
]

I also added my MIXPANEL_API_TOKEN to settings.py as well, and I have django-analytical==3.1.0 in my requirements.txt file.

I deployed these changes to a test website, so it's in prod, not dev.

I think I must be missing something -- should I be making any other code changes to enable tracking?

Thanks!

bittner commented 2 years ago

I think you're mixing up the generic setup for Analytical and the specific setup for Mixpanel.

Try to remove the {% mixpanel %} from your code. It should only be necessary if you don't (want to) use the generic setup.

Also, take a look at the generated code in your web browser. You should be able to see the JavaScript code snippet included in the HTML once.

Let us know if that works or if there is actually some issue with the integration!

serenamm commented 2 years ago

hI @bittner , thanks for your reply. You're right, I was mixing up the generic setupand the specific setup for Mixpanel. I removed the {% mixpanel %} tag and I do now see the JS code snippet show up when I view the source code on my browser.

I know this seems like an extremely simple question so thank you for helping me -- I don't see any events showing up in my Mixpanel dashboard. Should I be making any other code changes to enable tracking? Does django-analytical automatically track all clicks on the website? (I suspect the answer is "no", but I'm asking this as an example).

bittner commented 2 years ago

I can't answer this question for sure. Usually, our documentation walks you through the complete setup steps, at least on the Django side.

Note that Analytical is really just a template tag library that injects a JavaScript code snippet into your Django templates. All the rest depends on the provider of the analytics service.

It could be that Mixpanel have changed their setup, and that the one that was contributed to Analytical is legacy. But really that's just guessing on my side, based on the fact that I can't find the code snippet we have in their documentation.

If you find out more please post your findings here for everyone to benefit. Thanks!

jcassee commented 2 years ago

I know this seems like an extremely simple question so thank you for helping me -- I don't see any events showing up in my Mixpanel dashboard. Should I be making any other code changes to enable tracking? Does django-analytical automatically track all clicks on the website? (I suspect the answer is "no", but I'm asking this as an example).

I can answer that. Because it's not obvious what events are "interesting", django-analytical will not send any events itself. There is some hints about sending events yourself in the documentation, and a very old issue (#10) on doing something generic.