Querying Device Information for Shoppers with Purchases
If you are sending purchase events to Google Analytics 4 via the Measurement Protocol API, you cannot directly send geolocation or user device parameters to Google for the purchase.
However, if you're sending page_view events client-side, and are stitching together the server-side purchase event tracking before sending to the Measurement Protocol API, you can use simple session stitching to build this report.
See the SQL script below. Update the FROM statement with your Google BigQuery dataset ID.
WITH UsersWithPurchase AS (
-- Identify users who have made a purchase between Sept 19 to October 19
SELECT DISTINCT
user_pseudo_id
FROM
`PROJECT.DATASET.events_intraday_*`
WHERE
event_name = 'purchase' AND
event_timestamp BETWEEN UNIX_MICROS(TIMESTAMP("2023-09-19 00:00:00 UTC")) AND UNIX_MICROS(TIMESTAMP("2023-10-19 23:59:59 UTC"))
)
-- Retrieve device details for page views of users who made a purchase and group by device combination
SELECT
IFNULL(e.device.category, 'Unknown') AS device_category,
IFNULL(e.device.mobile_brand_name, 'Unknown') AS device_brand,
IFNULL(e.device.mobile_model_name, 'Unknown') AS device_model,
IFNULL(e.device.web_info.browser, 'Unknown') AS browser,
COUNT(DISTINCT e.user_pseudo_id) AS user_count
FROM
`ga-bigquery-integration-367223.analytics_266861172.events_intraday_*` e
JOIN
UsersWithPurchase u ON e.user_pseudo_id = u.user_pseudo_id
WHERE
e.event_name = 'page_view' AND
e.event_timestamp BETWEEN UNIX_MICROS(TIMESTAMP("2023-09-19 00:00:00 UTC")) AND UNIX_MICROS(TIMESTAMP("2023-10-19 23:59:59 UTC"))
GROUP BY
device_category, device_brand, device_model, browser
ORDER BY
user_count DESC