Skip to content

Add/ga4 schemas #1387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jun 12, 2025
Merged

Add/ga4 schemas #1387

merged 16 commits into from
Jun 12, 2025

Conversation

adatzer
Copy link
Contributor

@adatzer adatzer commented Feb 13, 2024

This PR cherry-picks #1245 and splits adding the schemas into commits.
The events are documented here: https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag

@jethron jethron changed the base branch from master to release/r167 April 30, 2025 23:30
@jethron jethron requested a review from miike April 30, 2025 23:31
@jbeemster jbeemster requested a review from istreeter May 2, 2025 07:06
Copy link
Collaborator

@istreeter istreeter left a comment

Choose a reason for hiding this comment

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

The schemas look good. My only comment is about monetary values.

A field with "type": "number" will get loaded into the warehouse as a double. If you add "multipleOf": 0.01 then it gets loaded as a decimal, which might be more convenient for the end user working with the data. (Although I am not an expert in how analysts work with this data).

See for example the following schemas which specify a multipleOf for monetary values:

  • schemas/com.google.analytics.ecommerce/item/jsonschema/1-0-0
  • schemas/com.google.analytics.ecommerce/transaction/jsonschema/1-0-0
  • schemas/com.google.analytics.enhanced-ecommerce/actionFieldObject/jsonschema/1-0-0
  • schemas/com.google.analytics.enhanced-ecommerce/impressionFieldObject/jsonschema/1-0-0
  • schemas/com.google.analytics.enhanced-ecommerce/productFieldObject/jsonschema/1-0-0
  • schemas/com.google.analytics.measurement-protocol/item/jsonschema/1-0-0
  • schemas/com.google.analytics.measurement-protocol/product/jsonschema/1-0-0
  • schemas/com.google.analytics.measurement-protocol/product_impression/jsonschema/1-0-0
  • schemas/com.google.analytics.measurement-protocol/transaction/jsonschema/1-0-0
  • schemas/com.snowplowanalytics.snowplow.ecommerce/cart/jsonschema/1-0-0
  • schemas/com.snowplowanalytics.snowplow.ecommerce/product/jsonschema/1-0-0
  • schemas/com.snowplowanalytics.snowplow.ecommerce/refund/jsonschema/1-0-0
  • schemas/com.snowplowanalytics.snowplow.ecommerce/transaction/jsonschema/1-0-0

@AlexBenny AlexBenny requested a review from greg-el May 12, 2025 15:46
Copy link
Contributor

@greg-el greg-el left a comment

Choose a reason for hiding this comment

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

These look good to me, can't find any discrepancies with the GA4 events.

@miike
Copy link
Contributor

miike commented May 22, 2025

If you add "multipleOf": 0.01 then it gets loaded as a decimal, which might be more convenient for the end user working with the data. (Although I am not an expert in how analysts work with this data).

@istreeter this makes sense, the other schemas are a little bit incorrect here (we need multipleOf 0.001) for consistency with three decimal place currencies. This will still create a decimal with the correct scale right?

If so I'm happy to update.

@istreeter
Copy link
Collaborator

I confirm multipleOf 0.001 will still create a decimal field. So that sounds like a good solution.

@miike
Copy link
Contributor

miike commented May 23, 2025

Thanks for confirming @istreeter.

I've added multipleOf for fields where it feels required, primarily for ecommerce. I left virtual currencies as is because for invented currencies (or things like crypto) we don't know what scale is necessarily being used.

@greg-el Do you mind giving this another once over and then we can hopefully get it merged? Thanks.

@miike miike requested review from greg-el and istreeter May 23, 2025 04:33
Copy link
Contributor

@greg-el greg-el left a comment

Choose a reason for hiding this comment

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

The multipleOf changes look good. LGTM assuming the changes are split out into the relevant commits.

adatzer added 15 commits May 30, 2025 17:39
@AlexBenny
Copy link
Contributor

I've splitted out mike's changes to the relevant commits

Copy link
Contributor

@AlexBenny AlexBenny left a comment

Choose a reason for hiding this comment

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

@miike @greg-el can you quickly check the comments I raised?
In a few places the field is nullable but also required.
They are technically valid but ambiguous. I'd like to check with you if this is by design or a mistake.

"properties": {
"score": {
"description": "The score to post.",
"type": ["number", "null"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we okay to keep it nullable even if it's a required field?
(for ref: https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#post_score)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, null is fine here.

"maxLength": 500
}
},
"required": ["virtual_currency_name", "value"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah no issue, this just means you can send null in here if you want to.

"maxLength": 500
}
},
"required": ["achievement_id"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Required but nullable. Is it ok?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep.

Copy link
Contributor

@AlexBenny AlexBenny left a comment

Choose a reason for hiding this comment

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

LGTM

@istreeter istreeter merged commit d05d5fe into release/r167 Jun 12, 2025
1 of 2 checks passed
@istreeter istreeter deleted the add/ga4_schemas branch June 12, 2025 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants