Write your tracking plan πŸ“‘ΒΆ

GAUnit offers various ways to define a tracking plan. Below, you will use a JSON file. You could also use Google Sheets or Python dictionaries to define which events you expect for your test case, but that’s for later (see How Tos).

First, create a tracking_plan.json file where you specify the expected events:

{
   "test_cases": {
      "demo_store_add_to_cart": {
         "events": [
            {
               "t": "pageview",
               "dt": "Home"
            },
            {
               "t": "pageview",
               "dt": "Product View"
            },
            {
               "t": "event",
               "ec": "ecommerce",
               "ea": "add_to_cart",
               "ev": "44",
               "pr1nm": "Compton T-Shirt",
               "pr1pr": "44.00"
            }
         ]
      }
   }
}

Few remarks here:

  • In a tracking plan, you can define more than one test case. Which is normal, given that you may have several test cases for your website!

  • Here, we named our test case demo_store_add_to_cart

  • For this test case, you expect at least 3 events:
    • the Home page view,

    • the Product View page view,

    • the Add To Cart click (with event value "ev" and product price "pr1pr")

Note

GAUnit is compatible with all versions of GA: analytics.js, gtag.js and GA4 properties