2
0

add_tracking_scripts.rst 2.9 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" (which is discontinued as of July 2023):
  16. * **Google Analytics 4 (GA4)** account IDs begin with **G-**
  17. * **Universal Analytics** account IDs begin with **UA-**. Google shut
  18. down UA accounts in July 2023, so these will no longer work.
  19. .. deprecated:: 3.0
  20. Support for Universal Analytics was removed in CRX version 3.0.
  21. Google Tag Manager (GTM)
  22. ------------------------
  23. Google Tag Manager (GTM) lets you add **one** script to your site. Then, from
  24. the `Google Tag Manager Console <https://tagmanager.google.com/>`_, you can add
  25. multiple other tracking scripts (Such as Google Analytics, Adwords, Facebook
  26. Pixels, HubSpot, Salesforce, Pardot, StatCounter, Adobe, etc.). GTM makes it
  27. convenient for your marketing staff to continually add and change the tracking
  28. tools without having to make any changes to the website.
  29. .. important::
  30. If you are using Google Tag Manager, you should remove any other tracking
  31. scripts from your site (including the **G-** and **UA-** IDs above), and add
  32. them through the `Google Tag Manager Console
  33. <https://tagmanager.google.com/>`_ instead.
  34. Other Scripts
  35. -------------
  36. If you have other tracking codes to add, follow these steps:
  37. #. In the Wagtail admin, go to **Settings > Tracking**.
  38. #. The tracking scripts will usually give you instructions of where to place
  39. them. So, make sure to verify the instructions that were given to you.
  40. #. Copy and paste scripts that should be between the ``<head>`` tags in the box
  41. labeled for ``<head>`` scripts.
  42. #. Copy and paste scripts that should be toward the closing ``<body>`` tag in
  43. the box labeled for ``<body>`` scripts.
  44. #. Click **Save** and you're done!
  45. .. figure:: img/head-body-scripts-widgets.png
  46. :alt: The TRACKING dashboard.
  47. The tracking dashboard.
  48. .. note::
  49. You can verify that the scripts are on the web page by going to the site and
  50. inspecting the source sode. Then search for the ``<script>`` tags, either
  51. visually or by hitting ``CTRL + F`` on your keyboard and searching for the
  52. code. Here's how to view the source code if you are not sure:
  53. * Firefox: https://developer.mozilla.org/en-US/docs/Tools/View_source
  54. * Chrome: https://support.google.com/surveys/answer/6172725?hl=en
  55. * Edge: https://docs.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/resources/