mirror of
https://github.com/jazzband/django-analytical.git
synced 2026-03-16 22:20:25 +00:00
Adding tracking support
Added tracking support
This commit is contained in:
parent
37009f2e08
commit
40493faabb
1 changed files with 15 additions and 2 deletions
|
|
@ -14,6 +14,8 @@ from analytical.utils import (
|
|||
get_identity,
|
||||
get_required_setting,
|
||||
is_internal_ip,
|
||||
build_paq_cmd,
|
||||
get_event_bind_js
|
||||
)
|
||||
|
||||
# domain name (characters separated by a dot), optional port, optional URI path, no slash
|
||||
|
|
@ -48,10 +50,8 @@ DEFAULT_SCOPE = 'page'
|
|||
|
||||
MatomoVar = namedtuple('MatomoVar', ('index', 'name', 'value', 'scope'))
|
||||
|
||||
|
||||
register = Library()
|
||||
|
||||
|
||||
@register.tag
|
||||
def matomo(parser, token):
|
||||
"""
|
||||
|
|
@ -97,6 +97,19 @@ class MatomoNode(Node):
|
|||
if getattr(settings, 'MATOMO_DISABLE_COOKIES', False):
|
||||
commands.append(DISABLE_COOKIES_CODE)
|
||||
|
||||
if getattr(settings, "MATOMO_REQUIRE_CONSENT", False):
|
||||
grant_class_name = settings.GRANT_CONSENT_TAG_CLASSNAME
|
||||
revoke_class_name = settings.REVOKE_CONSENT_CLASSNAME
|
||||
commands.append(build_paq_cmd('requireConsent'))
|
||||
commands.append(get_event_bind_js(
|
||||
class_name=grant_class_name,
|
||||
matomo_event="rememberConsentGiven",
|
||||
))
|
||||
commands.append(get_event_bind_js(
|
||||
class_name=revoke_class_name,
|
||||
matomo_event="forgetConsentGiven",
|
||||
))
|
||||
|
||||
userid = get_identity(context, 'matomo')
|
||||
if userid is not None:
|
||||
variables_code = chain(variables_code, (
|
||||
|
|
|
|||
Loading…
Reference in a new issue