From 938f1f2a63f40abb4a6ce9bc59ed1c12a8309e74 Mon Sep 17 00:00:00 2001 From: Eric Massip Date: Tue, 2 May 2023 20:09:52 +0100 Subject: [PATCH] Added explicit python code blocks in the docs --- docs/services/google_analytics_gtag.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/services/google_analytics_gtag.rst b/docs/services/google_analytics_gtag.rst index 3656f76..9760930 100644 --- a/docs/services/google_analytics_gtag.rst +++ b/docs/services/google_analytics_gtag.rst @@ -133,6 +133,8 @@ variable must be set to a dictionary where the keys are the dimension names and the values are the dimension values. You can set the context variable in your view when you render a template containing the tracking code:: +.. code-block:: python + context = RequestContext({ 'google_analytics_custom_dimensions': { 'gender': 'female', @@ -151,6 +153,8 @@ sending user properties to Google Analytics automatically. You may want to set custom dimensions in a context processor that you add to the :data:`TEMPLATE_CONTEXT_PROCESSORS` list in :file:`settings.py`:: +.. code-block:: python + def google_analytics_segment_language(request): try: return {'google_analytics_custom_dimensions': {'language': request.LANGUAGE_CODE}}