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
Homepage view,the
Product Viewpage view,the
Add To Cartclick (with event value"ev"and product price"pr1pr")
Note
GAUnit is compatible with all versions of GA: analytics.js, gtag.js and GA4 properties