I have integrated the Google Analytics API into Google Sheets for my reporting needs, but I’m facing problems when trying to capture transaction and revenue data while applying filters.
The API successfully retrieves revenue and transaction data when there are no filters, but I need to use a specific filter to differentiate between our brands as each has a unique affiliate ID. Here’s the filter I’m using:
ga:pagePath=@/?affiliate_id=default
While this filter works for session data, it fails to show any transaction or revenue amounts. In the standard Google Analytics interface, this filter retrieves the correct transaction and revenue figures, but when using the API in Sheets, it returns zero for both.
Can anyone help me identify what might be going wrong? Also, what should I enter in the filter box to correctly pull in transaction and revenue data?
I appreciate any suggestions, as my technical background is limited. Thank you!
Your problem is that Google Analytics attributes ecommerce data differently than page-level data. When you filter by ga:pagePath, you’re only viewing sessions that accessed that specific page, but transactions can be assigned to other pages in the conversion funnel. Avoid using ga:pagePath for affiliate tracking. Instead, consider using ga:dimension with a custom affiliate dimension, if available. If not, ga:sourceMedium or ga:medium filters may help you capture affiliate information at the traffic source level. Additionally, modifying your tracking to send affiliate_id as a custom dimension with ecommerce hits could also be beneficial. This way, you can filter transaction data directly, ensuring better alignment with how GA collects and attributes your transaction data.
I encountered a similar issue when working with Google Analytics API in the past. It’s crucial to understand that GA associates transactions with complete sessions rather than individual page interactions. By filtering with ga:pagePath, you might overlook broader session data that includes transactions.
To resolve this, consider using session-level filters such as ga:sourceMedium or ga:campaign, which often include affiliate details. Additionally, if you have set up a ga:customDimension for affiliate tracking, that could be beneficial. Another option is to use ga:landingPagePath for filtering, as it tends to correlate better with transaction data. Remember, the goal is to analyze data at the session level for accurate transactional insights.
had the same headache last month! the problem is you’re filtering transactions by page visits, but GA doesn’t always connect transactions to that specific page. try using ga:sourceMedium=affiliate/default or set up enhanced ecommerce tracking with custom dimensions for affiliate IDs. that’s what worked for me.