<@U07FJ89LFFB> does the React SDK send data to the...
# ask-ai
w
@brash-pillow-71627 does the React SDK send data to the datalayer so I can get the experiment id and variation ID with Google tag manager?
o
A message from kapa.ai
The React SDK of GrowthBook does not directly send data to the DataLayer. However, you can set up a tracking callback to send the experiment and variation IDs to the DataLayer. Here's an example of how you can do this:
Copy code
javascript window.growthbook = new GrowthBook({     // ...other config options...     trackingCallback: (experiment, result) => {         // Send data to the DataLayer         window.dataLayer.push({             'event': 'experiment_viewed',             'experiment_id': experiment.key,             'variation_id': result.variationId         });     } });
This code will send an event to the DataLayer whenever a user views an experiment. The event will include the experiment ID and the variation ID. You can then use Google Tag Manager to forward this event to your analytics tool of choice. For more information, you can refer to the [GrowthBook documentation](https://docs.growthbook.io/guide/google-tag-manager-and-growthbook#tracking-via-datalayer-and-gtm) and the [forum conversation](https://linen.growthbook.io/t/16933284/struggling-with-growth-2-9s-new-html-script-tag-sdk-and-goog) where this issue was discussed.