mirror of
https://github.com/jazzband/django-analytical.git
synced 2026-03-16 22:20:25 +00:00
more fixes to the docs
This commit is contained in:
parent
f56a779b7a
commit
47a5a4d6a9
2 changed files with 40 additions and 9 deletions
|
|
@ -78,6 +78,7 @@ providers send you can do it by setting the ``analytical_identity`` context
|
|||
variable in your view code:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
context = RequestContext({'analytical_identity': user.uuid})
|
||||
return some_template.render(context)
|
||||
|
||||
|
|
@ -89,6 +90,32 @@ or in the template:
|
|||
{% analytical_head_top %}
|
||||
{% endwith %}
|
||||
|
||||
or in context proessor:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# FILE: myproject/context_processors.py
|
||||
from django.conf import settings
|
||||
|
||||
def get_identity(request):
|
||||
return {
|
||||
'analytical_identity': 'some-value-here',
|
||||
}
|
||||
|
||||
# FILE: myproject/settings.py
|
||||
TEMPLATES = [
|
||||
{
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'myproject.context_processors.get_identity',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
That allows you as a developer to leave your view code untouched and
|
||||
make sure that the variable is injected for all templates.
|
||||
|
||||
If you want to change the identity only for specific provider use the
|
||||
``*_identity`` context variable, where ``*``-prefix is the module name
|
||||
of the specific provider.
|
||||
|
|
|
|||
|
|
@ -94,22 +94,26 @@ Identifying authenticated users
|
|||
-------------------------------
|
||||
|
||||
The username of an authenticated user is passed to Google Analytics
|
||||
automatically as the `user_id`. See :ref:`identifying-visitors`.
|
||||
automatically as the ``user_id``. See :ref:`identifying-visitors`.
|
||||
|
||||
According to `Google Analytics conditions`_ you should avoid ...
|
||||
|
||||
.. _`Google Analytics conditions`: https://developers.google.com/analytics/solutions/crm-integration#user_id
|
||||
you should avoid sending Personally Identifiable Information.
|
||||
Using `username` as `user_id` might not be the best option.
|
||||
According to `Google Analytics conditions`_ you should avoid
|
||||
sending Personally Identifiable Information.
|
||||
Using ``username`` as ``user_id`` might not be the best option.
|
||||
To avoid that, you can change the identity
|
||||
by setting `google_analytics_gtag_identity` (or `analytical_identity` to
|
||||
affect all providers) context variable::
|
||||
by setting ``google_analytics_gtag_identity`` (or ``analytical_identity`` to
|
||||
affect all providers) context variable:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
context = RequestContext({'google_analytics_gtag_identity': user.uuid})
|
||||
return some_template.render(context)
|
||||
|
||||
or in the template::
|
||||
or in the template:
|
||||
|
||||
.. code-block:: django
|
||||
|
||||
{% with google_analytics_gtag_identity=request.user.uuid|default:None %}
|
||||
{% analytical_head_top %}
|
||||
{% endwith %}
|
||||
|
||||
.. _`Google Analytics conditions`: https://developers.google.com/analytics/solutions/crm-integration#user_id
|
||||
|
|
|
|||
Loading…
Reference in a new issue