Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use GA4 data for DashboardTopEarningPagesWidget #8059

Closed
1 task
tofumatt opened this issue Jan 8, 2024 · 16 comments
Closed
1 task

Use GA4 data for DashboardTopEarningPagesWidget #8059

tofumatt opened this issue Jan 8, 2024 · 16 comments
Labels
Module: Analytics Google Analytics module related issues P1 Medium priority Type: Feature New feature

Comments

@tofumatt
Copy link
Collaborator

tofumatt commented Jan 8, 2024

Feature Description

The DashboardTopEarningPagesWidgetGA4 should be updated to use GA4 data/APIs once #8048 is available to detect AdSense linked accounts in GA4 properties.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation Brief

In assets/js/modules/adsense/components/dashboard/DashboardTopEarningPagesWidgetGA4.js:

  • Wait for the completion of the merge of Display Top Earning Pages Widget with a CTA to ask users to link their AdSense and Analytics when both modules are connected #8050.
  • Copy the contents from DashboardTopEarningPagesWidget.js into DashboardTopEarningPagesWidgetGA4.js.
  • Displaying the AdSenseLinkCTA based on the adSenseLinked account setting is being implemented in #8050.
  • Update the following selectors to use MODULES_ANALYTICS_4 store instead of MODULES_ANALYTICS:
    • isGatheringData
    • getReport
    • getErrorForSelector
    • hasFinishedResolution
    • getAdsenseLinked
    • getServiceReportURL
  • Construct the report arguments object with the necessary properties, including a dimension filter for the AdSense account. This object should be structured as follows and passed to the getReport selector:
    • dimensions: [ 'pageTitle', 'pagePath', 'adSourceName' ]
    • metrics: [ { name: 'totalAdRevenue' } ],
    • dimensionFilter: { filter: { fieldName: 'adSourceName', stringFilter: { matchType: 'EXACT', value: 'Google AdSense account (pub-XXXXX)', }, }, } (Replace pub-XXXXX with the actual AdSense account ID. See Querying AdSense metrics via Analytics 4)
    • orderBys: [ { metric: { metricName: 'totalAdRevenue' } } ],
    • limit: 5.
  • Update the tableColumns array with the following:
    • Get the the title and the url from row.dimensionValues instead of row.dimensions.
    • Get the service URL from getServiceReportURL with the unifiedPagePathScreen filters and pass it to the Link component.
    • Update the field to metricValues.0.value instead of metrics.0.values.0.
  • Pass data?.rows to the rows prop of the ReportTable component instead of data?.[ 0 ]?.data?.rows.

Test Coverage

  • Add possible stories in DashboardTopEarningPagesWidgetGA4.stories.js.
  • Add VRT scenarios for the stories.

Test Coverage

QA Brief

  • Enable the ga4AdSenseIntegration feature flag
  • Connect both Analytics and Adsense module and ensure the selected property and adsense accounts are linked.
  • Visit SK dashboard and run the following snippet on Browser Console to fore linked state.
    • googlesitekit.data.dispatch('modules/analytics-4').setAdSenseLinked(true)
  • The Widget with data should show up in the monetization section.
  • Check view only dashboard.

When the ga4AdSenseIntegration feature flag is disabled, this KMW tile should not appear.

Changelog entry

  • Use Google Analytics 4 API to get revenue data for pages in the "Top earning pages" widget when user has linked AdSense and Analytics account.
@tofumatt tofumatt self-assigned this Jan 8, 2024
@tofumatt tofumatt added the Module: Analytics Google Analytics module related issues label Jan 8, 2024
@tofumatt tofumatt removed their assignment Jan 9, 2024
@hussain-t hussain-t self-assigned this Jan 9, 2024
@bethanylang bethanylang added the P1 Medium priority label Jan 16, 2024
@tofumatt
Copy link
Collaborator Author

Note: parts of the logic for rendering this widget is covered in #8050. This IB should add the loading || isGatheringData === undefined logic from here though:

if ( loading || isGatheringData === undefined ) {
return (
<Widget noPadding Footer={ Footer }>
<PreviewTable rows={ 5 } padding />
</Widget>
);
}

@bethanylang bethanylang added the Next Up Issues to prioritize for definition label Jan 25, 2024
@hussain-t
Copy link
Collaborator

Hi @aaemnnosttv @tofumatt, I've encountered a challenge as we progress with this. In the GA4 migration documentation, I couldn't locate the GA4 equivalents for ga:adsenseRevenue, ga:adsenseECPM, and ga:adsensePageImpressions. It appears that totalAdRevenue might correspond to ga:adsenseRevenue, but the direct mappings for the other two metrics are unclear. Additionally, I found some extra metrics in this support guide. The Analytics UI provides some insight into the new metrics, but this implies we'll need to adapt our widget and revise the design doc accordingly. Could you give me insights or guidance on approaching these metric mappings and the widget modification?

@aaemnnosttv
Copy link
Collaborator

@hussain-t as noted in the design doc (see Querying AdSense metrics via Analytics 4), there is not an equivalent for these metrics, but the only one we're really concerned about is totalAdRevenue which we need to filter for the specific AdSense account to get the numbers just for AdSense.

While the legacy component we're reimplementing here has references to other metrics in it as you pointed out, they aren't actually used in its current state. It could be those were removed from the presentation at some point without being removed from the report we request, but the component will only show linked page titles with one column for earnings (revenue).

Let me know if you have any other questions 👍

@hussain-t
Copy link
Collaborator

Sounds good. Thanks, @aaemnnosttv 👍

@hussain-t hussain-t removed their assignment Jan 26, 2024
@aaemnnosttv aaemnnosttv self-assigned this Jan 26, 2024
@aaemnnosttv
Copy link
Collaborator

Construct the report arguments object with the following properties and pass it to the getReport selector:

  • dimensions: pageTitle and pagePath,
  • metrics: totalAdRevenue

@hussain-t please refer to the part of the design doc I referenced in the comment above. totalAdRevenue is not AdSense-specific and could contain revenue from other sources, or even other AdSense accounts than the one connected in SK. In order to get accurate metrics, we need to apply filtering in the request.

@aaemnnosttv aaemnnosttv assigned hussain-t and unassigned aaemnnosttv Jan 26, 2024
@hussain-t
Copy link
Collaborator

hussain-t commented Jan 29, 2024

Thanks, @aaemnnosttv. I've updated the IB to include the dimension filters. I've also verified it using https://ga-dev-tools.google/ga4/query-explorer/. Please LMK if that looks good.

@hussain-t
Copy link
Collaborator

Hi @tofumatt @bethanylang, I have marked this issue as blocked due to its dependency on #8050. Displaying the AdSenseLinkCTA based on the adSenseLinked account setting is being implemented in 8050. Please refer to this comment and this.

@hussain-t hussain-t assigned aaemnnosttv and unassigned hussain-t Jan 29, 2024
@bethanylang
Copy link
Collaborator

Thanks @hussain-t! Heads up for @ivonac4 as well as she's managing sprints at the moment.

@ivonac4
Copy link
Collaborator

ivonac4 commented Jan 29, 2024

Thanks for the info, updated in the Epic tracker and Design doc.

@aaemnnosttv
Copy link
Collaborator

  • dimensions: [ 'pageTitle', 'pagePath', 'adSourceName' ]

@hussain-t I don't think we need to include adSourceName as a dimension in the request since we won't display that anywhere, it should only be needed as a filter. We can confirm this during execution/review though.

getAdsenseLinked

FWIW, this is getAdSenseLinked in GA4.

IB ✅

@aaemnnosttv aaemnnosttv removed their assignment Feb 13, 2024
@zutigrm zutigrm self-assigned this Feb 14, 2024
@zutigrm
Copy link
Collaborator

zutigrm commented Feb 14, 2024

There is still a pending issue in execution before the blocking dependency in MR can be merged. Un-assigning myself until this is ready to be worked on

@zutigrm zutigrm assigned zutigrm and unassigned zutigrm Feb 14, 2024
@zutigrm
Copy link
Collaborator

zutigrm commented Feb 14, 2024

Got a confirmation that blocking issues will most likely be merged tomorrow, assigning myself back

@zutigrm zutigrm removed their assignment Feb 14, 2024
@bethanylang bethanylang removed the Next Up Issues to prioritize for definition label Feb 14, 2024
@kuasha420 kuasha420 self-assigned this Feb 14, 2024
@kuasha420 kuasha420 added the Type: Feature New feature label Feb 15, 2024
@kuasha420 kuasha420 removed their assignment Feb 19, 2024
@tofumatt tofumatt assigned tofumatt and kuasha420 and unassigned tofumatt Feb 19, 2024
@kuasha420 kuasha420 assigned tofumatt and kuasha420 and unassigned kuasha420 Feb 19, 2024
@tofumatt
Copy link
Collaborator Author

I've checked with @marrrmarrr to see whether this tile should filter out non-AdSense revenue or not. Currently it doesn't, which is expected from a QA perspective (eg. revenue from other sources should appear, see: https://10up.slack.com/archives/CBKKQEBR9/p1708348963677589?thread_ts=1708348556.944389&cid=CBKKQEBR9).

If it should be filtered, we'll file a follow-up issue.

@mohitwp
Copy link
Collaborator

mohitwp commented Feb 20, 2024

QA Update ⚠️

  • Tested on dev environment.
  • Tested by running code snippet in console.
  • Verified DashboardTopEarningPagesWidget shows up with data.

@kuasha420

Question > There is some data difference between DashboardTopEarningPagesWidget and 'Top Earning Pages" KM widget. I'm expecting that revenue data for pages in both widgets will be similaer. But see below screenshots under KM Widget revenue data for `[What do “L” or “N” car stickers mean in Ireland? – Oi.ie – Brasileiros na Irlanda] page is different in both widget in KM it is $0.55 and in Dashboard widget it is $0.51. Key metrics data is more close to actual revenue which is $0.56.

image

image

image

@kuasha420
Copy link
Collaborator

@mohitwp Thanks for the findings! This is a known issue and will be fixed in #8281 where data for both sources will be filtered by AdSense only. Cheers!

@kuasha420 kuasha420 removed their assignment Feb 20, 2024
@mohitwp
Copy link
Collaborator

mohitwp commented Feb 21, 2024

QA Update ✅

image

@mohitwp mohitwp removed their assignment Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: Analytics Google Analytics module related issues P1 Medium priority Type: Feature New feature
Projects
None yet
Development

No branches or pull requests

9 participants