2
0

add_tracking_scripts.rst 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. Add Tracking Scripts
  2. ====================
  3. Tracking scripts, such as Google Analytics or Facebook Pixels, can be added to
  4. the ``<head>`` and ``<body>`` of all of your web pages.
  5. Tracking settings are located in the Wagtail Admin dashboard under
  6. **Settings > Tracking**.
  7. .. warning::
  8. Keep in mind that **each script you add will slow your site down** and may
  9. affect your data privacy compliance such as GDPR. Therefore we recommend to
  10. carefully evaluate and choose one tracking solution that best fits your
  11. needs.
  12. Google Analytics
  13. ----------------
  14. There are two types of Google Analytics accounts --- "Google Analytics 4" (GA4)
  15. and "Universal Analytics" (for old accounts created before 2021):
  16. * **Google Analytics 4 (GA4)** account IDs begin with **G-**
  17. * **Universal Analytics** account IDs begin with **UA-**. Google is shutting
  18. down UA accounts in July 2023, so it is recommended to use GA4 accounts
  19. instead.
  20. * If you are using both account types, you can enter both IDs and the data will
  21. populate both accounts.
  22. Google Tag Manager (GTM)
  23. ------------------------
  24. Google Tag Manager (GTM) lets you add **one** script to your site. Then, from
  25. the `Google Tag Manager Console <https://tagmanager.google.com/>`_, you can add
  26. multiple other tracking scripts (Such as Google Analytics, Adwords, Facebook
  27. Pixels, HubSpot, Salesforce, Pardot, StatCounter, Adobe, etc.). GTM makes it
  28. convenient for your marketing staff to continually add and change the tracking
  29. tools without having to make any changes to the website.
  30. .. important::
  31. If you are using Google Tag Manager, you should remove any other tracking
  32. scripts from your site (including the **G-** and **UA-** IDs above), and add
  33. them through the `Google Tag Manager Console
  34. <https://tagmanager.google.com/>`_ instead.
  35. Other Scripts
  36. -------------
  37. If you have other tracking codes to add, follow these steps:
  38. #. In the Wagtail admin, go to **Settings > Tracking**.
  39. #. The tracking scripts will usually give you instructions of where to place
  40. them. So, make sure to verify the instructions that were given to you.
  41. #. Copy and paste scripts that should be between the ``<head>`` tags in the box
  42. labeled for ``<head>`` scripts.
  43. #. Copy and paste scripts that should be toward the closing ``<body>`` tag in
  44. the box labeled for ``<body>`` scripts.
  45. #. Click **Save** and you're done!
  46. .. figure:: img/head-body-scripts-widgets.png
  47. :alt: The TRACKING dashboard.
  48. The tracking dashboard.
  49. .. note::
  50. You can verify that the scripts are on the web page by going to the site and
  51. inspecting the source sode. Then search for the ``<script>`` tags, either
  52. visually or by hitting ``CTRL + F`` on your keyboard and searching for the
  53. code. Here's how to view the source code if you are not sure:
  54. * Firefox: https://developer.mozilla.org/en-US/docs/Tools/View_source
  55. * Chrome: https://support.google.com/surveys/answer/6172725?hl=en
  56. * Edge: https://docs.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/resources/