Respecting Consent ( Possible fix for #141 )
SilverStrings024 opened this issue · 6 comments
I saw #141 asking about how to respect the users choice when it comes to tracking and I was wondering why we can't just define a dotted path to a function that will tell if the user accepted or rejected tracking in settings.py and make the template tag comment out the tracking code if the function returns False like it does if the users ip address is an internal ip.
It's an easy, fast, non-obstructive fix for something I would imagine a lot of us need (me included).
Sounds like a good idea!
If you feel that #142 is not good enough of a PR do you want to try and open an alternative one as a contribution?
Sounds like a good idea!
If you feel that #142 is not good enough of a PR do you want to try and open an alternative one as a contribution?
I probably should have looked at the PRs huh? lol my apologies.
but, I'll take a look at the current code and see if there's anything I can come up with improvement wise.
Edit: After looking at the PR from 2019 I might have an idea for easier updating in the future as well as an idea to let users push things that aren't in the package (like enableHeartbeatTimer
) but that needs more working out. I'll clone it, code it up and run some tests. If everything works out, I'll submit a PR
Edit 2: I made it so we don't need to add any hardcoded things like enableHeartbeatTimer
in future updates. So now we can call
utils.build_paq_cmd('enableHeartbeatTimer')
which returns a paq command like this
_paq.push(['enableHeartbeatTimer'])
that we can use in the template tags. Note that this function accepts arguments and can likely be used to build events to be pushed to _paq
on element click.
Since an event needs to be bound to the consent button, do you care if I make it so we can let users bind events dynamically? So people could make a loop that binds certain events to certain things in their own template tags. That could even make it so you can conditionally track your users.
So, after making that, if someone wanted to make Matomo track a button but wanted to do it with python, they could do this
analytical.utils.bind_event_js(matomo_event="contentInteraction", class_name="someCoolButton", args=['coolCategory', 'coolName'])
which will bind an element to an onClick event whose handler pushes the command that build_paq_cmd()
spat out to _paq
So when the user clicks on the button with the class name 'someCoolButton' a contentInteraction
event is pushed to _paq
with the params we got in the call to bind_event()
@bittner I finished the PR but git was saying I wasn't allowed to push from my command line so I just uploaded the PR in files.
You need create your own fork of this repository, push the changes to your own fork (that will work) and place a PR from there.
You need create your own fork of this repository, push the changes to your own fork (that will work) and place a PR from there.
OOOOOOH sigh wow. Alright, thank you. I came up with a much better solution. Once I get this working, I'll be pushing
PR #193 Takes care of this