6 min read

How to Calculate Conversion Rate in Google Analytics 4

Conversion rate is one of the most important metrics for evaluating business performance, but calculating it in GA4 requires understanding how the platform structures conversion data. Unlike Universal Analytics where conversions were a distinct metric, GA4 treats conversions as a special classification applied to events. This means you need to mark the right events as conversions before you can measure your conversion rate.

Mark Events as Conversions

GA4 won't track an event as a conversion until you explicitly mark it. This is a one-time setup in your GA4 property admin.

Step 1: Mark an Event as Conversion in the UI

Go to Admin > Events in your GA4 property. Find the event you want to track as a conversion (e.g., purchase, signup, contact_form_submit). Click the event name and toggle Mark as conversion. The checkmark appears in the Conversion column. This tells GA4 to aggregate this event as a conversion metric.

Step 2: Track Conversion Events with gtag()

On the client side, use the gtag() function to send your conversion event with all relevant parameters. For an e-commerce purchase, include transaction details like value, currency, and items. GA4 automatically sends this to your property once you mark the event as a conversion.

javascript
// Track a purchase conversion with gtag()
gtag('event', 'purchase', {
  transaction_id: 'TXN_12345',
  value: 129.99,
  currency: 'USD',
  items: [
    {
      item_id: 'PROD_789',
      item_name: 'Premium Widget',
      item_category: 'Widgets',
      price: 129.99,
      quantity: 1
    }
  ]
});

// Track a sign-up conversion
gtag('event', 'sign_up', {
  method: 'email'
});
Use standard event names like purchase and sign_up so GA4 auto-populates conversion settings.
Tip: GA4 recognizes standard event names like purchase, sign_up, and contact. Use these names whenever possible so GA4 auto-populates the conversion settings.

Query Conversion Data with the Data API

Once you've marked events as conversions, use the Google Analytics Data API to fetch conversion metrics and calculate your conversion rate programmatically.

Step 1: Set Up the Data API Client

Install the @google-analytics/data package and initialize the client with your service account credentials. This allows you to query GA4 data from a backend service or scheduled job.

javascript
const {BetaAnalyticsDataClient} = require('@google-analytics/data');

const analyticsDataClient = new BetaAnalyticsDataClient({
  keyFilename: './service-account-key.json'
});

const propertyId = '123456789'; // Your GA4 property ID
Download your service account key from Google Cloud Console and save it locally.

Step 2: Fetch Conversion and Session Metrics

Use runReport() to fetch conversions and sessions metrics for your date range. The API returns aggregated metrics keyed by your dimensions (e.g., date, country). Then calculate conversion rate as (conversions / sessions × 100).

javascript
async function getConversionRate(propertyId, days = 30) {
  const response = await analyticsDataClient.runReport({
    property: `properties/${propertyId}`,
    dateRanges: [
      {
        startDate: `${days}daysAgo`,
        endDate: 'today'
      }
    ],
    metrics: [
      {name: 'sessions'},
      {name: 'conversions'}
    ]
  });

  const rows = response[0].rows;
  const sessions = parseInt(rows[0].metricValues[0].value);
  const conversions = parseInt(rows[0].metricValues[1].value);
  
  const conversionRate = ((conversions / sessions) * 100).toFixed(2);
  console.log(`Conversion Rate: ${conversionRate}%`);
  
  return conversionRate;
}

await getConversionRate('123456789', 30);
The metrics array specifies which metrics to retrieve. Always request both conversions and sessions to calculate rate.

Step 3: Segment Conversion Rate by Dimension

To calculate conversion rate by channel, device, or country, add a dimensions array to your report request. GA4 returns one row per dimension value, so you can calculate conversion rate for each segment separately.

javascript
async function getConversionRateByChannel(propertyId) {
  const response = await analyticsDataClient.runReport({
    property: `properties/${propertyId}`,
    dateRanges: [{startDate: '30daysAgo', endDate: 'today'}],
    dimensions: [{name: 'sessionDefaultChannelGroup'}],
    metrics: [
      {name: 'sessions'},
      {name: 'conversions'}
    ]
  });

  response[0].rows.forEach(row => {
    const channel = row.dimensionValues[0].value;
    const sessions = parseInt(row.metricValues[0].value);
    const conversions = parseInt(row.metricValues[1].value);
    const rate = ((conversions / sessions) * 100).toFixed(2);
    console.log(`${channel}: ${rate}%`);
  });
}

await getConversionRateByChannel('123456789');
Common dimensions: sessionDefaultChannelGroup, deviceCategory, country, date. Use these to break down conversion performance.
Watch out: GA4 has a 24-hour reporting delay. Newly marked conversion events won't appear in reports until the next day.

Calculate Conversion Rate for Specific User Cohorts

Sometimes you need conversion rate for a specific audience segment—new users, returning users, or users from a particular source. Use the dimensionFilter to isolate cohorts.

Step 1: Filter for New vs. Returning Users

Add a dimensionFilter to your report request to isolate specific user cohorts. For example, filter for newVsReturning == 'new' to calculate conversion rate for first-time visitors only.

javascript
async function getNewUserConversionRate(propertyId) {
  const response = await analyticsDataClient.runReport({
    property: `properties/${propertyId}`,
    dateRanges: [{startDate: '30daysAgo', endDate: 'today'}],
    dimensions: [{name: 'newVsReturning'}],
    metrics: [
      {name: 'sessions'},
      {name: 'conversions'}
    ],
    dimensionFilter: {
      filter: {
        fieldName: 'newVsReturning',
        stringFilter: {value: 'new'}
      }
    }
  });

  const row = response[0].rows[0];
  const sessions = parseInt(row.metricValues[0].value);
  const conversions = parseInt(row.metricValues[1].value);
  const rate = ((conversions / sessions) * 100).toFixed(2);
  console.log(`New User Conversion Rate: ${rate}%`);
  
  return rate;
}

await getNewUserConversionRate('123456789');
Use dimensionFilter for string-based filters like newVsReturning, country, or deviceCategory.
Tip: Conversion rate for new users is typically lower than returning users. Track both separately to identify onboarding friction.

Common Pitfalls

  • Not marking your events as conversions in the GA4 UI — the event may be firing correctly, but GA4 won't count it as a conversion metric until you explicitly mark it.
  • Using sessions vs. users inconsistently — conversion rate can be calculated either way, but you must be clear which denominator you're using. Session-based rates are more common for e-commerce; user-based rates work better for subscription products.
  • Ignoring the 24-hour reporting delay — newly marked conversion events won't appear in the Data API for up to 24 hours. Plan your automation around this latency.
  • Confusing the Conversions metric with individual conversion events — GA4 aggregates all marked conversion events into a single conversions metric. If you mark multiple events as conversions, they all count toward the same metric.

Wrapping Up

You now have three ways to calculate conversion rate in GA4: using the UI Reports tab for quick checks, querying the Data API for programmatic access, and filtering by user cohorts to understand which segments convert best. Understanding the difference between events and conversions, and calculating rate consistently, sets you up for reliable tracking. If you want to track this automatically across tools, Product Analyst can help.

Track these metrics automatically

Product Analyst connects to your stack and surfaces the insights that matter.

Try Product Analyst — Free