Power Query in Excel lets you import, clean, transform, and load data from Google Analytics (GA) into your workbook for analysis without manual copying. This guide shows how to connect Excel to GA using Power Query, prepare the data for reporting, and avoid common pitfalls.

What You'll Need

  • Microsoft Excel 2016 or later (Windows) with Power Query enabled (built-in in these versions)
  • A Google Analytics account with edit or view permissions on the property you want to query
  • The Google Analytics connector for Power Query (available via Microsoft AppSource or as a built-in connector in newer Excel versions)
  • An internet connection to authenticate with Google’s servers
  • Basic familiarity with Excel worksheets and the Power Query Editor interface

Step-by-Step

  1. Open Excel and create a new blank workbook. Go to the Data tab on the ribbon.
  2. In the Get & Transform Data group, click Get Data → From Online Services → From Google Analytics. If you don’t see this option, click Get Data → More… and search for “Google Analytics” in the connector list.
  3. A sign-in window will appear. Click Sign in and enter your Google account credentials associated with the GA property. Grant permission for Excel to access your Google Analytics data when prompted.
  4. After signing in, the Navigator pane loads. Select the Google Analytics account, then the property, and finally the view (profile) you want to extract data from. Click Connect.
  5. In the Navigator, choose the GA4 or Universal Analytics dataset depending on your property type. For GA4, select Events or Pages and screens; for Universal Analytics, choose Explorer or Reporting views.
  6. Click Transform Data to open the Power Query Editor. Here, you can shape your data before loading it into Excel.
  7. Remove unnecessary columns: right-click column headers you don’t need (e.g., “Session ID”, “User ID” if not required) and select Remove. Keep only metrics like Sessions, Users, Page Views, and dimensions like Date, Page Path, Source/Medium.
  8. Format the Date column: select it, go to the Transform tab, choose Data Type → Date (not DateTime) to ensure clean grouping in reports.
  9. Rename columns for clarity: double-click a column header and type a readable name (e.g., change “pagePath” to “Landing Page”).
  10. Filter data if needed: click the filter arrow on a column (e.g., Source/Medium), uncheck Select All, then check only the values you want (e.g., “google / organic”).
  11. Aggregate data: go to the Transform tab, click Group By. Group by Date and Source/Medium, then add aggregations like Sum for Sessions and Users.
  12. Once your query is shaped correctly, click Close & Load in the Home tab. The data loads into a new worksheet as an Excel table.
  13. To refresh later, right-click the table and choose Refresh, or go to Data → Refresh All. You’ll be prompted to re-sign in if your Google token has expired.

Common Mistakes

  • Using the wrong Google account: signing in with a personal Gmail instead of the corporate account linked to GA causes access errors or empty datasets.
  • Selecting a GA4 property but trying to pull Universal Analytics metrics (like “Bounce Rate”), which aren’t available in the same way—GA4 uses engagement rate instead.
  • Leaving the Date column as DateTime: this creates duplicate rows for the same day if timestamps differ, inflating totals when summed.
  • Forgetting to remove auto-generated columns like “_ts” or “_id” that Power Query adds but aren’t useful for analysis.
  • Not setting the correct data type on numeric fields: leaving “Sessions” as text prevents summing and causes errors in pivot tables.
  • Attempting to refresh without internet access: Power Query cannot reach Google’s servers offline, leading to refresh failures.

Tips

  • Name your query meaningfully in the Power Query Editor’s Queries pane (right-click → Rename)—e.g., “GA_Sessions_by_Source”—so it’s easy to identify later.
  • Load only the data you need: applying filters and removing columns in Power Query reduces refresh time and workbook size.
  • Use the Advanced Editor (View tab) to see or copy the M code if you need to reuse or troubleshoot the query.
  • Schedule automatic refreshes if using Excel via OneDrive or SharePoint with Power BI integration—though native Excel doesn’t support scheduled refresh without Power BI.
  • Combine GA data with other sources (e.g., CRM exports) by loading multiple queries and merging them in Power Query using common keys like Date or Campaign ID.
  • If your GA property uses custom dimensions, ensure they’re selected in the Navigator before connecting—otherwise they won’t appear in the field list.

Troubleshooting

  • Sign-in fails or loops: Clear your browser cache or try signing in through an incognito window. Ensure you’re using a Google account with access to the GA property. If using 2FA, approve the prompt on your phone.
  • No data appears after connecting: In the Navigator, verify you selected the correct view (especially important in Universal Analytics where multiple views exist). Check that the date range in your query isn’t set to a period with no data (e.g., future dates).
  • Refresh error: “We couldn’t authenticate with the credentials provided”: This means your Google auth token expired. Go to Data → Queries & Connections, right-click the query → Properties → uncheck Preserve formatting and Enable background refresh, then click Refresh and sign in again.
  • Missing metrics like “Bounce Rate” in GA4: GA4 doesn’t have bounce rate; use Engagement rate or calculate it manually as (1 - bounce rate) if needed. Alternatively, stick to Universal Analytics if you rely on UA-specific metrics.
  • Query runs slowly or times out: Reduce the date range, add filters early (e.g., limit to last 30 days), and avoid pulling hit-level data unless necessary. Aggregated data loads much faster.
  • Data types revert after refresh: In Power Query, after setting a data type, right-click the column → Change Type → Date or Decimal Number. Do not rely on Excel’s formatting alone—set it in the query.

Frequently Asked Questions

Can I use Power Query to connect to Google Analytics on a Mac?

No, the Google Analytics connector in Power Query is only available in Excel for Windows. Mac users must export GA data as CSV or use third-party tools like Supermetrics or Power My Analytics.

Do I need a Google Cloud project or API key to use this connector?

No, the built-in Google Analytics connector uses OAuth authentication via your Google account—no manual API setup, project, or key is required.

Can I schedule automatic refreshes of GA data in Excel without Power BI?

Not natively. Excel alone cannot schedule refreshes; you’d need to open the file manually or use Power BI Service with a gateway for scheduled updates.

Why are my session numbers different between GA and Excel after import?

This often happens due to sampling in GA (especially in Universal Analytics) or differences in how metrics are calculated. Check if your GA view is sampled—look for the sampling notice at the top of GA reports. Power Query pulls unsampled data only if the property isn’t sampled.

Is it safe to share my Excel file with others if it contains GA query credentials?

No. The query stores encrypted tokens that could allow others to access your GA data. Avoid sharing the file, or recreate the query on each user’s machine using their own login.

Can I pull real-time GA data using Power Query?

No. The connector retrieves historical data only. Real-time GA views are not accessible via Power Query due to API limitations.