amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

🐛 Google Analytics 4 Related Bug:

Open paigevogie opened this issue 1 year ago • 2 comments

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 and ep.content_id are in the payload as expected. image

However, in the h1 click event, only dt is in the payload and not ep.content_id. image

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 the h1 click event and you will notice content_id is included in the page_view but missing from h1 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

paigevogie avatar Mar 01 '24 20:03 paigevogie

will take this on this sprint

erwinmombay avatar Mar 06 '24 23:03 erwinmombay

@erwinmombay Hi, I wanted to check in. Will you all be fixing this soon?

paigevogie avatar Apr 25 '24 15:04 paigevogie