BLOG

Google Analytics 4 - How to add GA4 to PythonAnywhere's Django blog.

tool

In this article, we will show you how to add Google Analytics 4 to your site to get user demographics and other data about your visitors.

The more you know about our visitors, the more you can use it to inform our site operation policy.

[Google Analytics 4] How to add GA4 to Django blog.

Create a Google account and obtain the "global site tag (gtag.js)" script at the following site.

Google Analytics
https://analytics.google.com/

Add that gtag.js in the html head tag of the template.

<!-- Google tag (gtag.js) -->
<script src="https://www.googletagmanager.com/gtag/js?id=xxxxxxxxxxx"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'xxxxxxxxxxx');
</script>

You will know the user demographics of visitors to your site.

To learn more, please visit Analytics Help.

Analytics Help
https://support.google.com/analytics/

You will also learn how to migrate from Universal Analytics to Google Analytics 4.

Please, try it.

  1. tool
  2. Google Analytics 4 - How to add GA4 to PythonAnywhere's Django blog.

AUTHOR

Almost 10 years have passed since I started learning web development. Learning web development has made my life more fulfilling. This is because the greatest benefit that can be obtained in the process of learning web development is that when you encounter difficulties, you acquire the attitude of actively searching for information to solve them on your own. And just as I learned a lot from the knowledge of my predecessors, I hope that by disseminating information in English, it will reach people around the world who want to learn web development. life is very short. I would be very happy if I could add even a little bit to your life by my outputting what I learned every day. Maybe the information is incorrect or outdated at times. I'll update when I find out.