> For the complete documentation index, see [llms.txt](https://learn.fueled.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learn.fueled.io/learning-center/recipes-and-open-source/working-with-ga4-data-in-bigquery/querying-device-information-for-shoppers-with-purchases.md).

# 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.

```sql
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
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.fueled.io/learning-center/recipes-and-open-source/working-with-ga4-data-in-bigquery/querying-device-information-for-shoppers-with-purchases.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
