GA4 and ChatGPT tricks for power users

GA4 and ChatGPT tricks for power users

Are you tired of sifting through mountains of data, drowning in analytics, and feeling like you’re always one step behind your digital marketing goals? Welcome to the era of GA4 Mastery, where the power of Google Analytics 4 (GA4) meets the limitless potential of ChatGPT. In this blog, we’re about to unlock the secrets that will forever change how you navigate the complex world of web analytics. Whether you’re a seasoned data wizard or just dipping your toes into the data-driven universe, these top five tips are your golden ticket to turbocharging your workflow, driving better insights, and achieving digital success like never before. So, tighten your seatbelt, because we’re embarking on a journey that will supercharge your GA4 game!

Create API report requests using natural language prompts

Imagine a world where you type a question like the one below and get a report in just a few seconds!

I would like to see activeusers and sessions by country and page for june of this year for my google analytics property 123456789

Sounds awesome and it’s possible today just by using a prompt like the one below in ChatGPT. Just remember to replace the highlighted lines with your desired values. If you have any custom dimensions and/or metrics you want to include as options you can just add them to the list of dimensions (L26) and metrics (L29).

The current date is 
29/09/2023

You are going to help me build the following JSON object 
'{
    "property_id": "",   
    "dateRanges": [
        {
              "startDate": "",
               "endDate": ""
         }
      ], 
      "dimensions": [
           {"name": ""}, 
       ], 
      "metrics": [
           {"name": ""}, 
       ] 
}'

This JSON object contains five string properties: dimensions, metrics, start_date, end_date and property_id.

The value of property_id is a large number but should be stored in the JSON object as a string.

The dimension's name property should match one or more of these values:
yearWeek, yearMonth, year, week, visible, virtualCurrencyName, videoUrl, videoTitle, videoProvider, userGender, userAgeBracket, unifiedScreenName, unifiedScreenClass, unifiedPageScreen, unifiedPagePathScreen, transactionId, testDataFilterName, testDataFilterId, streamName, streamId, sourcePlatform, sourceMedium, source, signedInWithUserId, shippingTier, sessionSourcePlatform, sessionSourceMedium, sessionSource, sessionSa360Source, sessionSa360Query, sessionSa360Medium, sessionSa360Keyword, sessionSa360EngineAccountType, sessionSa360EngineAccountName, sessionSa360EngineAccountId, sessionSa360CreativeFormat, sessionSa360CampaignName, sessionSa360CampaignId, sessionSa360AdGroupName, sessionMedium, sessionManualTerm, sessionManualAdContent, sessionGoogleAdsQuery, sessionGoogleAdsKeyword, sessionGoogleAdsCustomerId, sessionGoogleAdsCreativeId, sessionGoogleAdsCampaignType, sessionGoogleAdsCampaignName, sessionGoogleAdsCampaignId, sessionGoogleAdsAdNetworkType, sessionGoogleAdsAdGroupName, sessionGoogleAdsAdGroupId, sessionGoogleAdsAccountName, sessionDefaultChannelGroup, sessionCampaignName, sessionCampaignId, searchTerm, screenResolution, region, platformDeviceCategory, platform, percentScrolled, pageTitle, pageReferrer, pagePathPlusQueryString, pagePath, pageLocation, outbound, orderCoupon, operatingSystemWithVersion, operatingSystemVersion, operatingSystem, nthYear, nthWeek, nthMonth, nthMinute, nthHour, nthDay, newVsReturning, month, mobileDeviceModel, mobileDeviceMarketingName, mobileDeviceBranding, minute, method, medium, manualTerm, manualAdContent, linkUrl, linkText, linkId, linkDomain, linkClasses, level, languageCode, language, landingPagePlusQueryString, landingPage, itemVariant, itemPromotionName, itemPromotionId, itemPromotionCreativeSlot, itemPromotionCreativeName, itemName, itemLocationID, itemListPosition, itemListName, itemListId, itemId, itemCategory5, itemCategory4, itemCategory3, itemCategory2, itemCategory, itemBrand, itemAffiliation, isoYearIsoWeek, isoYear, isoWeek, isConversionEvent, hour, hostName, groupId, googleAdsQuery, googleAdsKeyword, googleAdsCustomerId, googleAdsCreativeId, googleAdsCampaignType, googleAdsCampaignName, googleAdsCampaignId, googleAdsAdNetworkType, googleAdsAdGroupName, googleAdsAdGroupId, googleAdsAccountName, fullPageUrl, firstUserSourcePlatform, firstUserSourceMedium, firstUserSource, firstUserMedium, firstUserManualTerm, firstUserManualAdContent, firstUserGoogleAdsQuery, firstUserGoogleAdsKeyword, firstUserGoogleAdsCustomerId, firstUserGoogleAdsCreativeId, firstUserGoogleAdsCampaignType, firstUserGoogleAdsCampaignName, firstUserGoogleAdsCampaignId, firstUserGoogleAdsAdNetworkType, firstUserGoogleAdsAdGroupName, firstUserGoogleAdsAdGroupId, firstUserGoogleAdsAccountName, firstUserDefaultChannelGroup, firstUserCampaignName, firstUserCampaignId, firstSessionDate, fileName, fileExtension, eventName, deviceModel, deviceCategory, defaultChannelGroup, dayOfWeekName, dayOfWeek, day, dateHourMinute, dateHour, date, currencyCode, countryId, country, continentId, continent, contentType, contentId, contentGroup, cohortNthWeek, cohortNthMonth, cohortNthDay, cohort, cityId, city, character, campaignName, campaignId, browser, brandingInterest, audienceName, appVersion, adUnitName, adSourceName, adFormat, achievementId

The metric's name property is one or more of the following  values:
wauPerMau, userEngagementDuration, userConversionRate, transactionsPerPurchaser, transactions, totalUsers, totalRevenue, totalPurchasers, totalAdRevenue, taxAmount, shippingAmount, sessionsPerUser, sessions, sessionConversionRate, scrolledUsers, screenPageViewsPerUser, screenPageViewsPerSession, screenPageViews, returnOnAdSpend, refundAmount, purchaserConversionRate, purchaseToViewRate, purchaseRevenue, publisherAdImpressions, publisherAdClicks, promotionViews, promotionClicks, organicGoogleSearchImpressions, organicGoogleSearchClicks, organicGoogleSearchClickThroughRate, organicGoogleSearchAveragePosition, newUsers, itemsViewedInPromotion, itemsViewedInList, itemsViewed, itemsPurchased, itemsClickedInPromotion, itemsClickedInList, itemsCheckedOut, itemsAddedToCart, itemViewEvents, itemRevenue, itemRefundAmount, itemPromotionClickThroughRate, itemListViewEvents, itemListClickThroughRate, itemListClickEvents, itemDiscountAmount, grossPurchaseRevenue, grossItemRevenue, firstTimePurchasersPerNewUser, firstTimePurchasers, firstTimePurchaserConversionRate, eventsPerSession, eventValue, eventCountPerUser, eventCount, engagementRate, engagedSessions, ecommercePurchases, dauPerWau, dauPerMau, crashFreeUsersRate, crashAffectedUsers, conversions, cohortTotalUsers, cohortActiveUsers, checkouts, cartToViewRate, bounceRate, averageSessionDuration, averageRevenuePerUser, averagePurchaseRevenuePerUser, averagePurchaseRevenuePerPayingUser, averagePurchaseRevenue, advertiserAdImpressions, advertiserAdCostPerConversion, advertiserAdCostPerClick, advertiserAdCost, advertiserAdClicks, addToCarts, adUnitExposure, activeUsers, active7DayUsers, active28DayUsers, active1DayUsers

You will be able to find all the values in the following string:
I would like to see activeusers and sessions by country and page for june of this year for my google analytics property 1234567890

The report request can be completed using GA4’s data API run report request. Keep in mind that the property ID should be removed from the JSON and included in the URL path of your API request.

Have GPT explain your traffic data

Are you tired of looking at reports and crunching numbers looking for valuable insights, ask GPT to do it for you! OK LLMs are not particularly good with numbers (yet) but most of the time they are doing a pretty decent job (especially GPT-4).

Steps you need to follow:

  1. Just get a CSV export of any GA4 report
  2. Ask GPT something like “Below is a Google Analytics export of my website’s traffic data by marketing channel. Do you recognize any interesting insights? <PASTE-CSV-CONTENTS-HERE>

Most of the time you will get pretty interesting results! Take a look at the insights ChatGPT unearthed for me when I provided my website’s traffic data by marketing channel compared for the past 2 months:

You can expect to get even more impressive results if you use Advanced Data Analysis (aka Code Interpreter) instead.

Ask GPT to suggest reports and KPIs to monitor

Just explain what you are trying to do and let it suggest to you where to focus your monitoring effort.

Write RegEx for filters

If you are not comfortable with RegEx just ask an LLM to write it for you (preferably not politely :P). Let’s examine this with the following examples:

Write a regex expression that will be true only for the following URLs:
- https://tzamtzis.gr/2023/digital-analytics/actionable-tips-tricks-when-working-with-llms/
- https://tzamtzis.gr/2023/digital-analytics/ga4-tools-and-tutorials-you-need-to-bookmark/
- https://tzamtzis.gr/2023/digital-analytics/should-we-be-nice-to-chatgpt/
- https://tzamtzis.gr/2023/business-life/9-management-styles-plus-tips-for-applying-each-type/

Write a regex expression that will be true only for strings containing the word “tzamtzis” and does not include the word “gpt”.

The great thing when using ChatGPT to generate RegEx is you will also get an explanation for the complete regex rule and a source code example in Python!

Panagiotis

Written By

Panagiotis (pronounced Panayotis) is a passionate G(r)eek with experience in digital analytics projects and website implementation. Fan of clear and effective processes, automation of tasks and problem-solving technical hacks. Hands-on experience with projects ranging from small to enterprise-level companies, starting from the communication with the customers and ending with the transformation of business requirements to the final deliverable.