'Hit Number attribute equivalent in GA4 Big Query

Is there an equivalent of the attribute Hit Number from UA structure into GA4 structure in Bigquery. i'm trying to identify a unique row/event but except using hash key generator.



Solution 1:[1]

So, in GA4 everything every hit is an event and there is no distinction between Hit types as in UA.

Say you want to know the total number of hits on a given day, e.g. October 25th this year:

select 
  count(distinct event_timestamp) as cnt_hits
from
  `analytics_123456789.events_*`
where
  _table_suffix = '20211025' and
  event_name = 'page_view'

In this case, the event 'page_view' is triggered every time someone sees any of your web's pages.

To get a better sense, if you had an event called 'added_to_cart', then inputing that in the previous WHERE clause and counting the distinct event_timestamps would give you the total hits on that specific event (which would be basically triggered by a specific action, as clicking the "Add to cart" button).

Solution 2:[2]

SELECT ROW_NUMBER() OVER (PARTITION BY user_pseudo_id ORDER BY user_pseudo_id,event_timestamp,event_name) AS user_event_number, * FROM Project-bq1.analytics_290070127.events_* WHERE _table_suffix between '20220501' and '20220510'

you can refer 'user_event_number' for hit number after running the code

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Aleix CC
Solution 2