🐛 Google Analytics 4 Related Bug: #39871
Labels
Component: amp-analytics
Component: GA4
Google Analytics 4 and AMP bug
needs sizing
P1: High Priority
Type: Bug
Description
GA4 events do not include custom event parameters that are defined in the config. According to this documentation, I would expect custom parameters to show up in the events. The behavior I've noticed is that the parameters in the config that are overriding google's default parameters (such as "page_title") show up across all events as expected. But the parameters in the config that are new/custom to our usage (such as "content_id") do not show up across all events and are only in the
page_view
event. I was able to reproduce this issue in the amp playground link provided.You can see in the
page_view
event,dt
andep.content_id
are in the payload as expected.However, in the
h1 click
event, onlydt
is in the payload and notep.content_id
.URL where we can debug and reproduce the problem
https://playground.amp.dev/#share=PCFkb2N0eXBlIGh0bWw+CjxodG1sIOKaoSBsYW5nPSJlbiI+CjxoZWFkPgo8bWV0YSBjaGFyc2V0PSJ1dGYtOCI+CiAgICA8dGl0bGU+YW1wLWFuYWx5dGljczwvdGl0bGU+CiAgICA8c2NyaXB0IGFzeW5jIHNyYz0iaHR0cHM6Ly9jZG4uYW1wcHJvamVjdC5vcmcvdjAuanMiPjwvc2NyaXB0PgogICAgPCEtLSAjIyBTZXR1cCAtLT4KICAgIDwhLS0gIEltcG9ydCB0aGUgYGFtcC1hbmFseXRpY3NgIGNvbXBvbmVudCBpbiB0aGUgaGVhZGVyLiAtLT4KICAgIDxzY3JpcHQgYXN5bmMgY3VzdG9tLWVsZW1lbnQ9ImFtcC1hbmFseXRpY3MiIHNyYz0iaHR0cHM6Ly9jZG4uYW1wcHJvamVjdC5vcmcvdjAvYW1wLWFuYWx5dGljcy0wLjEuanMiPjwvc2NyaXB0PgogICAgPCEtLQogICAgV2UgbmVlZCBgYW1wLWlmcmFtZWAgdG8gZW1iZWQgYW4gYW5hbHl0aWNzIGRhc2hib2FyZC4KICAtLT4KICAgIDxsaW5rIHJlbD0iY2Fub25pY2FsIiBocmVmPSJodHRwczovL2FtcC5kZXYvZG9jdW1lbnRhdGlvbi9leGFtcGxlcy9jb21wb25lbnRzL2FtcC1hbmFseXRpY3MvaW5kZXguaHRtbCI+CiAgICA8bWV0YSBuYW1lPSJ2aWV3cG9ydCIgY29udGVudD0id2lkdGg9ZGV2aWNlLXdpZHRoIj4gICAKICAJPHN0eWxlIGFtcC1ib2lsZXJwbGF0ZT48L3N0eWxlPgogIDxub3NjcmlwdD48c3R5bGUgYW1wLWJvaWxlcnBsYXRlPgogICAgICAgIGJvZHkgewogICAgICAgICAgLXdlYmtpdC1hbmltYXRpb246IG5vbmU7CiAgICAgICAgICAtbW96LWFuaW1hdGlvbjogbm9uZTsKICAgICAgICAgIC1tcy1hbmltYXRpb246IG5vbmU7CiAgICAgICAgICBhbmltYXRpb246IG5vbmU7CiAgICAgICAgfQogICAgICA8L3N0eWxlPjwvbm9zY3JpcHQ+CiAgPC9oZWFkPgogIDxib2R5PgogIDxoMT4KICAgIEhlbGxvIFdvcmxkCiAgPC9oMT4KPC9ib2R5PgogICAKICAgIDxhbXAtYW5hbHl0aWNzIHR5cGU9Imd0YWciIGRhdGEtY3JlZGVudGlhbHM9ImluY2x1ZGUiPgogICAgICA8c2NyaXB0IHR5cGU9ImFwcGxpY2F0aW9uL2pzb24iPgp7CiAgInZhcnMiOiB7CiAgICAiY29uZmlnIjogewogICAgICAiRy0xMTExIjogewogICAgICAgICJjb250ZW50X2lkIjogIjEyMzQ1IiwKICAgICAgICAicGFnZV90aXRsZSI6ICJIZWxsbyBXb3JsZCAxMjMiCiAgICAgIH0gICAgICAKICAgIH0KICB9LAogICJ0cmlnZ2VycyI6IHsKICAgICJoMV9jbGljayI6IHsKICAgICAgIm9uIjogImNsaWNrIiwKICAgICAgInNlbGVjdG9yIjogImgxIiwKICAgICAgInZhcnMiOiB7CiAgICAgICAgImV2ZW50X25hbWUiOiAiaDEgY2xpY2siCiAgICAgIH0KICAgIH0KICB9Cn0KICAgICAgPC9zY3JpcHQ+CiAgICA8L2FtcC1hbmFseXRpY3M+CiAgCjwvYm9keT48L2h0bWw+
Reproduction Steps
With the following GA4 AMP configuration, inspect the payload for the
page_view
event and theh1 click
event and you will noticecontent_id
is included in thepage_view
but missing fromh1 click
.<amp-analytics type="gtag" data-credentials="include"> <script type="application/json"> { "vars": { "config": { "G-1111": { "content_id": "12345", "page_title": "Hello World 123" } } }, "triggers": { "h1_click": { "on": "click", "selector": "h1", "vars": { "event_name": "h1 click" } } } } </script> </amp-analytics>
Relevant Logs
No response
Browser(s) Affected
No response
OS(s) Affected
No response
Device(s) Affected
No response
AMP Version Affected
No response
The text was updated successfully, but these errors were encountered: