Using the code added in #8045, we need to create a REST Route in our WordPress REST API Routes in the Analytics module for fetching AdSense accounts linked to Analytics accounts from the Google Analytics API.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
A new data point GET:adsense-links should be added to the Analytics_4 module.
It should take a GA4 Property ID as parameter and return the links between the provided GA4 property and AdSense account. ie. Google_Service_GoogleAnalyticsAdmin_GoogleAnalyticsAdminV1alphaAdSenseLink[]
If should not be shareable.
Implementation Brief
[x] Once the required infrastructure is in place via #8084, we will have Google\Site_Kit\Modules\Analytics_4\GoogleAnalyticsAdmin\PropertiesAdSenseLinksService and a service (TBD. ie. analyticsadsenselinks).
[x] In Google\Site_Kit\Modules\Analytics_4 class:
[x] In get_datapoint_definitions() method, add GET:adsense-links datapoint with the aforementioned service.
[x] In create_data_request() method, add a case for the above datapoint:
[x] If $data['propertyID'] is not set, return with a missing_required_param error.
[x] Otherwise, get the analyticsadsenselinks service and return $analyticsadmin->properties_adSenseLinks->listPropertiesAdSenseLinks( $parent ), where the $parent should be the normalized property ID. ie.self::normalize_property_id ($data['propertyID'] ).
[x] In parse_data_response() method, add a case for the above datapoint:
[x] Return (array) $response->getAdsenseLinks().
Test Coverage
Add PHPUnit test coverage for the newly added datapoint.
QA Brief
Connect the currently used GA4 property with an AdSense account.
Visit Site Kit
Run the following JS snippet in the console and verify that the connected AdSense accounts' client id is being returned inside the response.
Feature Description
Using the code added in #8045, we need to create a REST Route in our WordPress REST API Routes in the Analytics module for fetching AdSense accounts linked to Analytics accounts from the Google Analytics API.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
GET:adsense-links
should be added to theAnalytics_4
module.Google_Service_GoogleAnalyticsAdmin_GoogleAnalyticsAdminV1alphaAdSenseLink[]
Implementation Brief
Google\Site_Kit\Modules\Analytics_4\GoogleAnalyticsAdmin\PropertiesAdSenseLinksService
and a service (TBD. ie.analyticsadsenselinks
).Google\Site_Kit\Modules\Analytics_4
class:get_datapoint_definitions()
method, addGET:adsense-links
datapoint with the aforementioned service.create_data_request()
method, add a case for the above datapoint:$data['propertyID']
is not set, return with amissing_required_param
error.analyticsadsenselinks
service and return$analyticsadmin->properties_adSenseLinks->listPropertiesAdSenseLinks( $parent )
, where the$parent
should be the normalized property ID. ie.self::normalize_property_id ($data['propertyID'] )
.parse_data_response()
method, add a case for the above datapoint:(array) $response->getAdsenseLinks()
.Test Coverage
QA Brief
Changelog entry