From 96f1ba98b1a6867eeff8f6862ae4e9aa2efde049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Thu, 14 Jul 2022 12:08:41 +0200 Subject: [PATCH] add more information about overriding identity to documentation --- docs/features.rst | 20 ++++++++++++++++++++ docs/services/google_analytics_gtag.rst | 16 ++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/docs/features.rst b/docs/features.rst index 4485b92..6382bd5 100644 --- a/docs/features.rst +++ b/docs/features.rst @@ -68,3 +68,23 @@ and is enabled by default. To disable: Alternatively, add one of the variables to the context yourself when you render the template. + + +Changing the identity +********************* + +If you want to change identity of the user, that different providers are +sending, you can do it by setting the `analyitcal_identity` context variable:: + + context = RequestContext({'analytical_identity': user.uuid}) + return some_template.render(context) + +or in the template:: + + {% with analytical_identity=request.user.uuid|default:None %} + {% analytical_head_top %} + {% endwith %} + +If you want to change the identity only for specific provider, use the +`*_identity` context variable, where `*` is prefix specified on the provider +page. diff --git a/docs/services/google_analytics_gtag.rst b/docs/services/google_analytics_gtag.rst index 8e55e3e..ae94625 100644 --- a/docs/services/google_analytics_gtag.rst +++ b/docs/services/google_analytics_gtag.rst @@ -95,3 +95,19 @@ Identifying authenticated users The username of an authenticated user is passed to Google Analytics automatically as the `user_id`. See :ref:`identifying-visitors`. + +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:: + + context = RequestContext({'google_analytics_gtag_identity': user.uuid}) + return some_template.render(context) + +or in the template:: + + {% with google_analytics_gtag_identity=request.user.uuid|default:None %} + {% analytical_head_top %} + {% endwith %}