--- title: Analytics with Hydrogen and Oxygen description: Learn how to set up analytics with Hydrogen and Oxygen, and transmit metrics events to Shopify analytics. source_url: html: https://shopify.dev/docs/storefronts/headless/hydrogen/analytics md: https://shopify.dev/docs/storefronts/headless/hydrogen/analytics.md --- ExpandOn this page * [Consent tracking for analytics](https://shopify.dev/docs/storefronts/headless/hydrogen/analytics#consent-tracking-for-analytics) * [Tracking analytics events](https://shopify.dev/docs/storefronts/headless/hydrogen/analytics#tracking-analytics-events) # Analytics with Hydrogen and Oxygen Hydrogen provides recommended patterns for collecting and transmitting website metrics to Shopify analytics, which enables you to view metrics in real time, directly in the Shopify admin. *** ## Consent tracking for analytics Before you can track analytics on your Hydrogen storefront, ensure you comply with customer consent regulations. [![](https://shopify.dev/images/icons/48/key.png)![](https://shopify.dev/images/icons/48/key-dark.png)](https://shopify.dev/docs/storefronts/headless/hydrogen/analytics/consent) [Tracking consent with Shopify (recommended)](https://shopify.dev/docs/storefronts/headless/hydrogen/analytics/consent) [Use Shopify’s built-in Customer Privacy API and native cookie banner to get consent](https://shopify.dev/docs/storefronts/headless/hydrogen/analytics/consent) [![](https://shopify.dev/images/icons/48/globe.png)![](https://shopify.dev/images/icons/48/globe-dark.png)](https://shopify.dev/docs/storefronts/headless/hydrogen/analytics/consent-3p) [Third-party consent management services](https://shopify.dev/docs/storefronts/headless/hydrogen/analytics/consent-3p) [Integrate a third-party consent tracking service into Hydrogen](https://shopify.dev/docs/storefronts/headless/hydrogen/analytics/consent-3p) *** ## Tracking analytics events Analytics is built into Hydrogen, but you can implement it manually if required. You should also check that it's working as expected. [![](https://shopify.dev/images/icons/48/analytics.png)![](https://shopify.dev/images/icons/48/analytics-dark.png)](https://shopify.dev/docs/storefronts/headless/hydrogen/analytics/tracking) [Add Analytics components to Hydrogen](https://shopify.dev/docs/storefronts/headless/hydrogen/analytics/tracking) [Manually upgrade an older version of Hydrogen to use the built-in Analytics components](https://shopify.dev/docs/storefronts/headless/hydrogen/analytics/tracking) [![](https://shopify.dev/images/icons/48/clicode.png)![](https://shopify.dev/images/icons/48/clicode-dark.png)](https://shopify.dev/docs/storefronts/headless/hydrogen/analytics/validation) [Validate your analytics data](https://shopify.dev/docs/storefronts/headless/hydrogen/analytics/validation) [Check that analytics data is flowing and troubleshoot common issues](https://shopify.dev/docs/storefronts/headless/hydrogen/analytics/validation) *** * [Consent tracking for analytics](https://shopify.dev/docs/storefronts/headless/hydrogen/analytics#consent-tracking-for-analytics) * [Tracking analytics events](https://shopify.dev/docs/storefronts/headless/hydrogen/analytics#tracking-analytics-events)