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

Implement Google Tag container lookup and destinations list REST data points #6078

Closed
felixarntz opened this issue Oct 27, 2022 · 5 comments
Closed
Labels
Module: Analytics Google Analytics module related issues P0 High priority Rollover Issues which role over to the next sprint Type: Enhancement Improvement of an existing feature

Comments

@felixarntz
Copy link
Member

felixarntz commented Oct 27, 2022

REST data point wrappers for the new Tag Manager API endpoints for container lookup and listing destinations need to be implemented, as part of the Analytics_4 module, to get information on the Google Tag configuration for the GA4 web data stream.


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

Acceptance criteria

  • A new feature flag gteSupport should be added to Site Kit.
  • A new REST data point GET:container-lookup should be added to the Analytics_4 module class.
    • It should wrap the container lookup endpoint and return the found container object.
  • A new REST data point GET:container-destinations should be added to the Analytics_4 module class.
  • If the newly added gteSupport feature flag is enabled, the Analytics_4 module should, going forward, require the https://www.googleapis.com/auth/tagmanager.readonly scope.

Implementation Brief

  • Add a new feature flag gteSupport to feature-flags.json.
  • In Analytics_4::get_scopes(), add the https://www.googleapis.com/auth/tagmanager.readonly scope if the gteSupport feature flag is enabled.
  • In Analytics_4::get_datapoint_definitions:
    • Add a new REST data point GET:container-lookup with the value of the array containing service with the value tagmanager.
    • Add a new REST data point GET:container-destinations with the value of the array containing service with the value tagmanager.
  • In Analytics_4::create_data_request:
    • Add a new case for GET:container-lookup with the following:
      • Return the get_service( 'tagmanager' )::AccountsContainers::lookup method call.
      • Pass the optional parameter destinationID if it is set in $data['destinationID'].
    • Add a new case for GET:container-destinations with the following:
      • Validate the accountID and containerID parameters. If either is missing, return an error.
      • Return the get_service( 'tagmanager' )::AccountsContainersDestinations::listAccountsContainersDestinations method call.
      • Construct the parent parameter using the accountID and containerID parameters like: accounts/{account_id}/containers/{container_id} and pass it to the method call.
  • In Analytics_4::parse_data_response:
    • Add a new case for GET:container-lookup that should return the Container object of the response.
    • Add a new case for GET:container-destinations that should return the ListDestinationsResponse collection of the response.

Test Coverage

  • Update the Analytics_4::test_get_datapoints test to include the new data points.

QA Brief

  • Ensure the gteSupport feature flag is available.
  • Execute the container-lookup endpoint from the browser console and verify it returns the container object if available.
googlesitekit.api.get("modules", "analytics-4", "container-lookup", {destinationID: 'G-2C8N8YQ1L7'}, {useCache: false});
  • Replace the value of destinationID with yours. It can be obtained from the GTM console.
  • Execute the container-destinations endpoint from the browser console and verify it returns the destination array if available. Otherwise an empty array.
googlesitekit.api.get("modules", "analytics-4", "container-destinations", {accountID: '6005635295', internalContainerID: '56877720'}, {useCache: false});
  • Replace the value of the accountID and internalContainerID with yours. It can be obtained from the GTM console.

Changelog entry

  • Add Google Tag container lookup and destinations list datapoints.
@FlicHollis
Copy link
Collaborator

Hi @hussain-t when you are back next week, please could you prioritise this IB as it is blocking 6080 which is ready to go in the EB (It's also blocking 6079 which I can see you are also working on). Thanks!

@hussain-t hussain-t removed their assignment Nov 28, 2022
@techanvil techanvil self-assigned this Nov 28, 2022
@techanvil
Copy link
Collaborator

IB ✅

@techanvil techanvil removed their assignment Nov 28, 2022
@hussain-t hussain-t assigned hussain-t and unassigned hussain-t Dec 3, 2022
@hussain-t hussain-t removed their assignment Dec 12, 2022
@bethanylang bethanylang added the Rollover Issues which role over to the next sprint label Dec 16, 2022
@hussain-t hussain-t assigned aaemnnosttv and unassigned hussain-t Dec 22, 2022
@aaemnnosttv aaemnnosttv removed their assignment Dec 22, 2022
@wpdarren wpdarren self-assigned this Jan 3, 2023
@wpdarren
Copy link
Collaborator

wpdarren commented Jan 3, 2023

QA Update: ⚠️

@hussain-t when I run this code in console, an error appears.

googlesitekit.api.get("modules", "analytics-4", "container-lookup", {destinatonID: 'G-0C8SH75J0C'}, {useCache: false});

googlesitekit-vendor-e90c8879cff6b8ca1621.js:1          GET https://ng-caribou-cojo.instawp.xyz/wp-json/google-site-kit/v1/modules/analytics-4/data/container-lookup?destinatonID=G-0C8SH75J0C&_locale=user 400
googlesitekit-vendor-e90c8879cff6b8ca1621.js:1 Uncaught (in promise) {code: 'missing_required_param', message: 'Request parameter is empty: destinationID.', data: {…}}

image

I ran the containers lookup tool with the destination ID and that ran successfully.

For now, I have only run the first step.

Could you please check the QAB, and let me know if there's anything I am missing here? 🤔

@hussain-t
Copy link
Collaborator

Thanks, @wpdarren; my bad; there was a typo in the QAB. It should be destinationID instead of destinatonID. I have updated the QAB. The following is the correct one.

googlesitekit.api.get("modules", "analytics-4", "container-lookup", {destinationID: 'G-2C8N8YQ1L7'}, {useCache: false});

@wpdarren
Copy link
Collaborator

wpdarren commented Jan 3, 2023

QA Update: ✅

@hussain-t thank you for your help!

Verified:

  • Ran the code in the QAB and confirmed that it ran successfully with no errors. See screenshots for the results.
  • I also used the containers lookup and destination list tools to make sure the results were the same.

image
image

@wpdarren wpdarren removed their assignment Jan 3, 2023
@felixarntz felixarntz self-assigned this Jan 12, 2023
@felixarntz felixarntz removed their assignment Jan 12, 2023
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 P0 High priority Rollover Issues which role over to the next sprint Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

7 participants