Skip to content

Update itemCount check#50

Open
TayshawnH wants to merge 2 commits intomasterfrom
update-item-count-check
Open

Update itemCount check#50
TayshawnH wants to merge 2 commits intomasterfrom
update-item-count-check

Conversation

@TayshawnH
Copy link
Copy Markdown
Contributor

💸 TL;DR

We should use itemCount if it is supported for that event - https://business.reddithelp.com/s/article/about-event-metadata

@TayshawnH TayshawnH requested a review from a team as a code owner September 12, 2025 18:43
if (itemCount !== null) {
var parsedItemCount = makeNumber(itemCount);
if(data.eventType != "SignUp" && data.eventType != "sign_up" && data.eventType != "Lead" && data.eventType != "generate_lead") {
if(hasItemCount(data.eventType)) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with automatic collection of ecommerce data, we sometimes get itemCount attached to the view content event type causing diagnostic issues.

"add_to_wishlist": true,
"Purchase": true,
"purchase": true,
"Custom": true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to have custom?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think "custom" is a real GA4 event name. since we collect GA4 events we need to make sure that we are checking for the eventType we expect and ones that come from automatic GA4 mapping

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh so this is a combination of GA4 event names and Reddit Pixel event names?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eventMetadata.products = products;
}

var EVENTS_WITH_ITEM_COUNT = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the change here? We are reducing the number of events we pass item count along with?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah just making sure that we are not grabbing itemCount from unsupported event types. this map is the events that can use it

Copy link
Copy Markdown
Contributor

@felix-levert-reddit felix-levert-reddit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Is this only an issue with itemCount or should we do something similar with other metadata fields too?

@TayshawnH
Copy link
Copy Markdown
Contributor Author

@felix-levert-reddit this itemCount one is a bit different because of a direct conflict with how GA4 handles the view_item event. GA4's documentation shows that view_item can include an items array, and our template automatically calculates itemCount from the quantity in that array. this was causing events like ViewContent (which we map back from view_item) to be sent with itemCount and causing diagnostic issues.

should we do something similar with other metadata fields too?

but yeah good point, I should update the value and currency check as well to be more strict and exclude ViewContent, PageVisit, and Search

@TayshawnH
Copy link
Copy Markdown
Contributor Author

@felix-levert-reddit updated the check here - 0bf3233

@felix-levert-reddit
Copy link
Copy Markdown
Contributor

@TayshawnH Nice! Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants