react-ga4 icon indicating copy to clipboard operation
react-ga4 copied to clipboard

How to set multiple tracker with different tracker name

Open asif-jalil opened this issue 2 years ago • 4 comments

I want to set multiple tracker for different page. In react-ga package there is a option in gaOptions named name and for specific pageview event I called that tracker name. And then the metrics go to the corresponding analytic. How to achieve this situation for your package?

asif-jalil avatar Feb 23 '23 05:02 asif-jalil

I'm in the early stages of replacing react-ga with react-ga4 and need to accomplish the same thing. I was just reading about routing https://developers.google.com/tag-platform/gtagjs/routing. I'm wondering if we need to specify the name in the groups field instead of name, and then reference it in a send_to field when triggering any event, pageview, etc?

okcscott avatar Feb 24 '23 16:02 okcscott

ReactGA.event('page_view', { page_location: '/home', page_title: 'Home', send_to: 'G-XXX' });

You can specify which tracker to use by setting the send_to option.

melihcaliskanhnc avatar Mar 01 '23 11:03 melihcaliskanhnc

I'm trying to do the same thing but the send_to attribute never seems to be added to the api call sent to google. I'm trying to use an ad tracker and the syntax I'm using is:

ReactGA.event({ action: "conversion", category: "Conversion", label: "RCQ-XXXXXXXXXXXXXXXX", send_to: "AW-XXXXXXXXX/RCQ-XXXXXXXXXXXXXXXX", });

The event is received but the send_to attribute isn't included. This is what is received by google tag assistant :

API Call gtag("event", "Conversion", { event_category: "Conversion", event_label: "RCQ-XXXXXXXXXXXXXXXX", value: undefined, non_interaction: undefined })

The ID in the send_to AW-XXXXXXXXX has been added to the init array and is recognized so that works.

I have tried different permutations of the send_to attribute including send_to, sendTo. Sending as an array didn't make a difference.

I'm baffled.

Thanks in advance for any help!

kenadian avatar Mar 21 '23 21:03 kenadian

Hey @asif-jalil did you find a solution for this ?

pratyush0103 avatar Nov 25 '24 12:11 pratyush0103