Skip to content

Setup GoLinks for PDF Generation feature #12583

@benbowler

Description

@benbowler

Feature Description

Internal Site Kit deep links within the PDF (e.g. the "View on dashboard" CTA, plus the entity-dashboard links embedded in Key Metrics page lists, Audience Segmentation tiles, Top Content over Time, and Top Earning Pages) use the GoLinks system so that if Site Kit's internal URL patterns change in future, baked-in PDF links still resolve. External destinations (Google privacy policy, Site Kit help center, Search Console search.google.com links) are NOT proxied through GoLinks - they point directly to their canonical URLs since they do not benefit from the WordPress admin auth flow and are stable Google-owned URLs.


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

Acceptance criteria

  • Every internal Site Kit deep link a user clicks inside a downloaded PDF (the "View on dashboard" link, plus every page-entity link in Key Metrics, Audience Segmentation, Top Content, and Top Earning Pages) redirects through Site Kit's GoLinks system rather than going to a hard-coded destination, consistent with how Email Reporting internal links behave today.
  • If a user clicks an internal GoLink in a PDF while logged out of WordPress, they go through the standard WordPress authentication flow before landing on the destination (same behaviour as existing Email Reporting links).
  • External links inside the PDF (Google privacy policy, Site Kit help center, Search Console destinations on search.google.com) point directly to their canonical URLs and are NOT proxied through GoLinks.

Implementation Brief

Frontend (JavaScript) - client-side GoLinks helper

  • Create file assets/js/googlesitekit/datastore/site/golinks.ts - adds a getGoLinkURL( key, args = {} ) selector to CORE_SITE. Returns {adminURL}/index.php?action=googlesitekit_go&to={key} with any extra query args appended (e.g. permaLink for entity-dashboard links). Pure URL construction - no REST round-trip - because the shape is deterministic from the admin URL plus the handler key (see Golinks::get_url on the PHP side). Single place where the GoLink URL shape is defined on the client. Used by the PDF's "View on dashboard" CTA and by every entity-dashboard link in the Key Metrics page lists, Audience Segmentation tiles, Top Content over Time, and Top Earning Pages widgets. Search Console destinations (search.google.com) and other external URLs (privacy policy, help center) bypass this selector and link directly.
  • Update file assets/js/googlesitekit/datastore/site/index.js - register the new golinks sub-store alongside the existing urls, info, etc.

Test Coverage

  • Jest: assets/js/googlesitekit/datastore/site/golinks.test.ts - getGoLinkURL returns the expected URL shape for the dashboard key (no args), the entity-dashboard variant ({ permaLink: 'https://example.com/page' } appends permaLink correctly, including URL-encoding), handles arbitrary extra query args, and still produces a URL for unknown keys (server decides validity at click time).

QA Brief

Changelog entry

  • Add the getGoLinkURL( key, args = {} ) selector to the CORE_SITE datastore.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Medium priorityTeam SIssues for Squad 1Type: EnhancementImprovement of an existing feature

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions