Skip to content

gtag plugin should support multiple trackingID #8489

@slorber

Description

@slorber

Have you read the Contributing Guidelines on issues?

Description

The gtag plugin should only be used at most once per page, but we should be able to use it with multiple "Google Products" as documented here:
https://developers.google.com/tag-platform/gtagjs/install#add-products

Notably, it is important for the UA => GA4 transition (#7221) because for a smoother analytics migration, we want to collect analytics to the old UA id and to the new GA4 id
(from now on to June 2023 until collecting data for UA becomes useless, see #7221 for details).

In this case, we should call gtag("config",trackingID) multiple times.

gtag('config', 'G-XXXXX');
gtag('config', 'AW-XXXXX');
gtag('config', 'DC-XXXXX');

(ideally we should be able to provide different product configs for each config, but we can keep it simple for now and just support multiple configless ids)

Has this been requested on Canny?

No response

Motivation

Make the gtag plugin more powerful, tracking to multiple analytics accounts, tracking Google Ads...

API design

We should prevent duplicate usage by throwing an error if id !== "default"

We should allow passing trackingID: ["G-XXXXX","AW-XXXXX","DC-XXXXX"] as an array of strings instead of just one single string id.

Note: it might be worth studying if passing an array is enough.

We might as well want to use different configs for each?

See also
https://stackoverflow.com/questions/54280439/how-to-combine-ua-and-aw-tracking-tags

Have you tried building it?

No response

Self-service

  • I'd be willing to contribute this feature to Docusaurus myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    domain: analyticsRelated to the gtag/GA pluginsfeatureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.good first issueIf you are just getting started with Docusaurus, this issue should be a good place to begin.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions