worried-planet-2191
05/10/2023, 8:25 AMhelpful-application-7107
05/10/2023, 1:28 PMhelpful-application-7107
05/10/2023, 1:28 PM__rawExperiment as (
SELECT
user_id as user_id,
TIMESTAMP_MICROS(event_timestamp) as timestamp,
experiment_id_param.value.string_value AS experiment_id,
variation_id_param.value.int_value AS variation_id,
geo.country as country,
traffic_source.source as source,
traffic_source.medium as medium,
device.category as device,
device.web_info.browser as browser,
device.operating_system as os
FROM
(
SELECT
*
FROM
`analytics_356435236.events_*`
WHERE
_TABLE_SUFFIX BETWEEN '20230330' AND '20230512'
UNION ALL
SELECT
*
FROM
`analytics_356435236.events_intraday_*`
WHERE
_TABLE_SUFFIX BETWEEN '20230330' AND '20230512'
),
UNNEST (event_params) AS experiment_id_param,
UNNEST (event_params) AS variation_id_param
WHERE
event_name = 'experiment_viewed'
AND experiment_id_param.key = 'experiment_id'
AND variation_id_param.key = 'variation_id'
AND user_id is not null
)
SELECT
e.user_id as user_id,
cast(e.variation_id as string) as variation,
CAST(e.timestamp as DATETIME) as timestamp,
CAST(e.timestamp as DATETIME) as conversion_start,
DATETIME_ADD(CAST(e.timestamp as DATETIME), INTERVAL 72 HOUR) as conversion_end
FROM
__rawExperiment e
WHERE
e.experiment_id = 'new-secondary-panel-title'
AND CAST(e.timestamp as DATETIME) >= DATETIME("2023-03-30 17:01:00")helpful-application-7107
05/10/2023, 1:29 PMbusy-air-96466
05/10/2023, 2:27 PMbusy-air-96466
05/10/2023, 2:31 PMbusy-air-96466
05/10/2023, 3:45 PMconst growthbook = new GrowthBook({
apiHost: '<http://localhost:4100>',
clientKey: 'sdk-wwD7n4nfhRYZXeac',
enableDevMode: true,
trackingCallback: (experiment, result) => {
console.log(
'*** Experiment Viewed. experimentId:',
experiment.key,
'variationId:',
result.key,
);
// make sure a visual experiment based on Logged-in Users
// will send its experiment_viewed event after the Login event
// so that user_id is tracked with experiment results
setTimeout(() => {
// track using GA4
window.sendGA4event('experiment_viewed', {
event_category: 'experiment',
experiment_id: experiment.key,
variation_id: result.key,
});
}, 10);
},
});
Login is now sent before experiment_viewed for visual as well as SDK experiments: