Hi! We're trying to use the pre-built script tag w...
# ask-questions
Hi! We're trying to use the pre-built script tag with Webflow + Rudderstack as our eventing system. However, it doesn't appear that trackingCallback is firing, as we added in a console.log that's not showing up. Will post the code in the thread. We've gotten it working previously without using the pre-built script tag, so not sure if I'm just missing something super obvious and thought I'd ask 🙂
Copy code
<script type="text/javascript">
!function () {
        "use strict"; var sdkBaseUrl = "<https://cdn.rudderlabs.com/v3>"; var sdkName = "rsa.min.js"; var asyncScript = true
                ; window.rudderAnalyticsBuildType = "legacy", window.rudderanalytics = []
                ; var e = ["setDefaultInstanceKey", "load", "ready", "page", "track", "identify", "alias", "group", "getAnonymousId", "getSessionId", "reset", "setAnonymousId", "startSession", "endSession"]
                ; for (var t = 0; t < e.length; t++) {
                        var n = e[t]; window.rudderanalytics[n] = function (e) {
                                return function () {
                } try {
                        new Function('return import("")'), window.rudderAnalyticsBuildType = "modern"
                } catch (a) { }
        if (window.rudderAnalyticsMount = function () {
                "undefined" == typeof globalThis && (Object.defineProperty(Object.prototype, "__globalThis_magic__", {
                        get: function get() {
                                return this
                        }, configurable: true
                }), __globalThis_magic__.globalThis = __globalThis_magic__,
                        delete Object.prototype.__globalThis_magic__); var e = document.createElement("script")
                        ; e.src = "".concat(sdkBaseUrl, "/").concat(window.rudderAnalyticsBuildType, "/").concat(sdkName), e.async = asyncScript,
                                document.head ? document.head.appendChild(e) : document.body.appendChild(e)
        }, "undefined" == typeof Promise || "undefined" == typeof globalThis) {
                var d = document.createElement("script")
                ; d.src = "<https://polyfill.io/v3/polyfill.min.js?features=Symbol%2CPromise&callback=rudderAnalyticsMount>",
                        d.async = asyncScript, document.head ? document.head.appendChild(d) : document.body.appendChild(d)
        } else {
        } window.rudderanalytics.load("xxxxxx", "<https://ownhomemigmk.dataplane.rudderstack.com>", {})

  window.growthbook_config = window.growthbook_config || {};
  window.growthbook_config.trackingCallback = (experiment, result) => {
    console.log("Tracking callback called.");
    if (rudderanalytics && rudderanalytics.track) {
      rudderanalytics.track("Experiment Viewed", {
        anonymous_id: rudderanalytics.getAnonymousId(),
        experiment_id: experiment.key,
        variation_id: result.key
    } else {
      console.error("Rudderstack SDK or track method not available.");
  window.growthbook_config.attributes = {
    "anonymousId": rudderanalytics.getAnonymousId(),
    "sessionId": rudderanalytics.getSessionId()
<script async
And the* public page*
How have you defined the experiment?
that trackingCallback looks right, if the trackingCallback doesn't fire, sometimes it from the assignment id not being set
The experiment is set up as a visual editor experiment using anonymous_id - may well have done something wrong in the set up. Having checked - there is a slight discrepancy in that in our targeting attributes in the SDK configuration, it's in camel case, and in the script above + query it's set in in snake case. Could this be the source of the issue?
it could be
@fresh-football-47124 - I think in the end it was the Rudderanalytics script not being fully initialised? Di you have recommendations for how to assign randomisation for a frontend marketing experiment on visitors (i.e. anonymous or device ID). as above, we're currently using the Rudderstack SDK's anonymous ID, but this does slow down the load due to the above, so we are open to switching to a different way of doing it 🙂