-
-
Notifications
You must be signed in to change notification settings - Fork 170
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
Fixed gtag user_id setup and added support for custom dimensions #226
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, the tests fail for an infrastructure issue.
If you dare to fix it, it's ubuntu-latest
that needs to be replaced by ubuntu-20.04
in the GHA tests workflow. This is necessary, because Python 3.6 is not available anymore in the former VM image.
I don't want to ask too much, but if you really care you may want to open a separate PR to make the tests run against Django 4.2 (dropping 4.0) and Python 3.11 (in addition), and fix the pipeline issue there. That would be optimal.
References
- About GitHub-hosted runners (GHA docs)
- Django releases (officially supported versions)
- Supported Python versions: Django 3.2, Django 4.1, Django 4.2 (relevant for the test matrix in
tox.ini
)
pass custom dimensions to Google Analytics automatically. The ``google_analytics_custom_dimensions`` | ||
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:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use an explicit code-block here, as in the examples above.
.. code-block:: python
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Added here
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`:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use an explicit code-block here (instead of ::
), as in the examples above.
.. code-block:: python
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added here
@bittner Sure! I can fix the pipeline and update the Python and Django versions. I might need a few days to find the time but I'll do it 👍 |
I see the CI updates are already being taken care of in #227 👍 😁 |
Fixes #124
Fixes #197
Fixes #225
The correct way to send the
user_id
using thegtag
has changed according to the docs. I have applied the required changes to the code to comply with the new specification viagtag('config', ...)
as opposed togtag('set', ...)
.In addition, I decided to take the chance to add support for sending custom dimensions in GA4. Note that the custom dimensions are appended to the
gtag('config', ...)
command as a json serialized dictionary. There are (at least) two ways of adding custom dimensions that are sent along with every event withgtag
. One is by using the set command and the other one is by using the config command. IMO, the latter is more convenient because you can add theuser_id
to the rest of dimensions and send it all together in the same command, so that's how I did it, but I'm happy to be convinced otherwise 😊