Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respecting Consent ( Possible fix for #141 ) #192

Closed
SilverStrings024 opened this issue Jul 10, 2021 · 6 comments
Closed

Respecting Consent ( Possible fix for #141 ) #192

SilverStrings024 opened this issue Jul 10, 2021 · 6 comments

Comments

@SilverStrings024
Copy link

SilverStrings024 commented Jul 10, 2021

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).

@SilverStrings024 SilverStrings024 changed the title Detecting Consent Status Respecting Consent ( Possible fix for #141 ) Jul 10, 2021
@bittner
Copy link
Member

bittner commented Jul 11, 2021

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?

@SilverStrings024
Copy link
Author

SilverStrings024 commented Jul 12, 2021

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()

@SilverStrings024
Copy link
Author

SilverStrings024 commented Jul 12, 2021

@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.

@bittner
Copy link
Member

bittner commented Jul 13, 2021

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.

@SilverStrings024
Copy link
Author

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

@SilverStrings024
Copy link
Author

PR #193 Takes care of this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants