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

[Question] Can 'useGA4React' hook be used for sub-domains as well ? #10

Closed
mahesh-chotrani opened this issue Mar 1, 2021 · 1 comment
Labels
enhancement New feature or request question Further information is requested

Comments

@mahesh-chotrani
Copy link

While going through GA documentation, they do support multiple sub domains for which events can be recorded.

We have multiple domains (one for each customer, a.example.com, b.example.com, etc. ), and we want to roll up the data collected. This is in addition to per customer data collection.

I tried the same using the below example

const Example = () => {
  const ga4React1 = useGA4React('GA_CODE_I', {}, []); // GA CODE, optional, if empty try to get from globals
  console.log(ga4React1);
  . . .
  const ga4React2 = useGA4React('GA_CODE_II', {}, []); // GA CODE, optional, if empty try to get from globals
  console.log(ga4React2);
  . . .
  return <>{JSON.stringify(ga4React)}</>;
};

But the second object always found to be null. Is there anything missed out in above configuration ?

@unrealmanu
Copy link
Owner

I have not particularly tested this use, so if you find any problems, report them to me that I correct it, but I suggest you try this:

const ga = useGA4React("G-1JXXXXX,G-2JXXXXX");

or

const ga = useGA4React(["G-1JXXXXX","G-2JXXXXX"]);

and then to do that. you have to use the function directly gtag

@unrealmanu unrealmanu added question Further information is requested enhancement New feature or request labels Mar 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants