Hey guys, We're a bit stuck in the implementation...
# ask-questions
d
Hey guys, We're a bit stuck in the implementation of GrowthBook. Would really appreciate your help on this. Here's a quick video walkthrough of the issue: https://share.vidyard.com/watch/htVJi4jBBrPDL57nJq6c3a? Adding the scripts below we have on the website, for more context. This is the start of <head> tag script:
Copy code
<script>
window.growthbook_config = window.growthbook_config || {};
</script>
And the end of <head> tag script:
Copy code
<script>
    window.growthbook_config = {
        trackingCallback: function (experiment, result) {
            dataLayer.push({
                'event': 'experiment_viewed',
                'event_category': 'experiment',
                'experiment_id': experiment.key,
                'variation_id': result.variationId
            });
        }
    };

    window.growthbook_queue = window.growthbook_queue || [];
    window.growthbook_queue.push((gb) => {
        const applyFeatureFlags = () => {
            const h1FeatureValue = gb.getFeatureValue("feature-h1", "Invest in Dubai's most attractive rental properties for as little as AED 500");

            document.querySelectorAll("h1").forEach((h1) => {
                const originalText = h1.textContent;
                
                h1.textContent = h1FeatureValue;
                
                const span = document.createElement('span');
                if (h1FeatureValue.includes('attractive rental properties')) {
                    span.textContent = 'attractive rental properties';
                    span.style.color = "rgb(65, 206, 142)";
                    h1.innerHTML = h1.innerHTML.replace('attractive rental properties', span.outerHTML);
                }
                if (h1FeatureValue.includes('premium rental properties')) {
                    span.textContent = 'premium rental properties';
                    span.style.color = "rgb(65, 206, 142)";
                    h1.innerHTML = h1.innerHTML.replace('premium rental properties', span.outerHTML);
                }
            });
        };
        applyFeatureFlags();
        document.addEventListener("growthbookdata", applyFeatureFlags);
    });
</script>

<script async
    data-api-host="<https://cdn.growthbook.io>"
    data-client-key="sdk-0crYvL5bKqQKvMSb"
    src="<https://cdn.jsdelivr.net/npm/@growthbook/growthbook/dist/bundles/auto.min.js>"
></script>
s
Hey Pedro! Thanks for sharing. I'm not sure exactly what's happening, but the experiment exposure query is defined in your data source configuration. What do you see if you go to Metrics and DataData SourcesReshift, under Experiment Assignment Queries? This is where you tell GrowthBook where to find your experiment variation assignment events.
d
Thanks a lot Ryan! It seems I had mapped the wrong table, now added
growthbook.experiment_viewed
instead of just
experiment_viewed
. But now it's saying
experiment_id
is missing. Do we need to add
experiment_id
and
variation id
as well to the fact tables?
s
What are you trying to accomplish? Generally, you wouldn't be accessing the experiment viewed data as/in a fact table. Rather, the experiment exposure table is handled separately and fact tables are used for the metrics you want to optimize for. Then, in the experiment analysis, GrowthBook will look at the exposure data and join it to the chosen metrics to see how different variations perform.
d
Ok, I'm trying to see experiment results, if I click on the warning next to the Update button, it tells me experiment_viewed doesn't exit.
s
It sounds like you need to check your experiment assignment queries under Metrics and Data -> Data Sources. https://docs.growthbook.io/app/datasources#experiment-assignment-queries