Skip to content
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

event_date and event_timestamp are in UTC. Is that expected? #144

Closed
adamribaudo-velir opened this issue Mar 4, 2023 · 5 comments
Closed

Comments

@adamribaudo-velir
Copy link
Collaborator

As pointed out here, the event_timestamp field is in UTC: https://support.google.com/analytics/answer/7029846?hl=en#zippy=%2Cevent

I assume the event_date field is as well. My preference would be to convert these to the relevant reporting time zone as early in the pipeline as possible. Otherwise, users will need to handle this conversion in the BI layer which I'm certain will be overlooked frequently.

I propose a 'timezone' var that can be used to convert the event_timestamp and generate a new event_date_dt field in the base layer. (bigquery uses time zone names located here: http://www.iana.org/time-zones )

Curious to get input from others.

@willbryant
Copy link
Contributor

Pretty sure I found the table date suffixes and event_date_dt were actually the same timezone you chose for reporting GA4 settings, which was a pleasant surprise.

@adamribaudo-velir
Copy link
Collaborator Author

adamribaudo-velir commented Mar 4, 2023 via email

@willbryant
Copy link
Contributor

Huh. Ok, I’ll have a look at work tomorrow.

@adamribaudo-velir
Copy link
Collaborator Author

ok I'm with you now, just ran this and I get the exact same event counts per day

SELECT 
  DATE(TIMESTAMP_MICROS(event_timestamp) , "America/Los_Angeles") event_date, 
  count(event_timestamp) as event_count 
FROM `*****.events_*` 
where DATE(TIMESTAMP_MICROS(event_timestamp) , "America/Los_Angeles") >= '2023-02-01'
group by 1
order by event_date asc

image

I'll close this issue and add a comment in the .yml docs that event_timestamp & event_date are set to the property time zone

@willbryant
Copy link
Contributor

Just to clarify, event_timestamp is documented as being in UTC because the bigquery TIMESTAMP type is an universal "instant of time" value, which is shown in UTC in query results unless you ask for something else.

But for event_date_dt, DATE values aren't a universal "instant of time", so they need to be in a defined timezone.

So, event_timestamp should be documented as UTC as people will in practice need to use a query like the one you used to see it in their own timezone. They can convert to a DATETIME if they want that local TZ representation instead.

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

No branches or pull requests

2 participants