wide-cartoon-5349
09/10/2024, 2:33 PMorange-terabyte-33302
09/10/2024, 2:33 PMorange-terabyte-33302
09/10/2024, 2:34 PMjavascript trackingCallback: function(experiment, result) { // TODO: track experiment impression dataLayer.push({ 'event': 'experiment_viewed', 'user_id': gbuuid, 'experiment_id': experiment.key, 'variation_id': result.variationId, }); }
In this example, gbuuid
is the user ID, experiment.key
is the experiment ID, and result.variationId
is the variant ID. This function essentially adds a row to BigQuery that says "user123, saw variation 1, of this experiment, at this date/time". For non-logged-in users, you can generate a unique ID on the client side and use it as the "user ID". This ID should be persistent and used for other metric events as well. This way, you can match anonymous "user IDs" with purchases or other events. Remember, the ID you use for assignment/bucketing should also be available in BigQuery to join to the metric events. This means you should pass this ID to BigQuery so that the metrics will work. Sources: - [Forum Conversation > T > 16382394 Part 5](https://linen.growthbook.io/t/16382394/hello-i-am-facing-some-issue-with-growth-book-configuration-) - [Forum Conversation > T > 8145516 Part 2](https://linen.growthbook.io/t/8145516/hi-all-i-m-looking-into-using-growthbook-to-test-out-feature) - [Forum Conversation > T > 10358958](https://linen.growthbook.io/t/10358958/hey-i-am-having-a-landing-page-with-anonymous-users-i-am-pla)wide-cartoon-5349
09/10/2024, 2:36 PMorange-terabyte-33302
09/10/2024, 2:36 PMorange-terabyte-33302
09/10/2024, 2:37 PMgtag
function to send an event to GA4, which then sends the data to BigQuery. Here's an example of how you might do this with GA4: javascript trackingCallback: function(experiment, result) { // track with GA4 gtag("event", "experiment_viewed", { event_category: "experiment", experiment_id: experiment.key, variation_id: result.variationId, gb_user_id: gbuuid, }); }
In this example, gtag
is a function provided by GA4 for sending events. The event data includes the experiment ID, variant ID, and user ID. GA4 then sends this data to BigQuery. If you're not using GA4 or another service that can send data to BigQuery, you would need to use a BigQuery client library to send the data directly from your application. This would involve creating a BigQuery client, creating a dataset and table in BigQuery, and inserting rows into the table. The details of this process would depend on the programming language you're using. Please refer to the [BigQuery documentation](https://cloud.google.com/bigquery/docs) for more information on how to send data to BigQuery directly from your application. Sources: - [Forum Conversation > T > 16382394 Part 5](https://linen.growthbook.io/t/16382394/hello-i-am-facing-some-issue-with-growth-book-configuration-) - [Forum Conversation > T > 8145516 Part 2](https://linen.growthbook.io/t/8145516/hi-all-i-m-looking-into-using-growthbook-to-test-out-feature) - [Forum Conversation > T > 10358958](https://linen.growthbook.io/t/10358958/hey-i-am-having-a-landing-page-with-anonymous-users-i-am-pla)