Hi, We had implemented rudderstack using JS SDK in...
# support
a
Hi, We had implemented rudderstack using JS SDK in one of our static pages and was facing some issues with events not being triggered when using
rudderstack.track()
in the production environment. Is this function asynchronous?
k
CC <!subteam^S04QT1G74Q3|@sdk-team>
h
Are you using CDN or NPM package?
a
We are using CDN. @high-zoo-17436
h
Right way to call track is
rudderanalytics.track(event, [properties], [apiOptions], [callback]);
More info
a
We are trying to figure out if the
rudderstack.track()
is synchronous or not. We are doubting that the redirection logic is getting executed before the tracking function completes its execution. If the function is async, we can simply use await to solve this issue. Please provide some insight over this. Attaching below the code for reference.
Copy code
rudderanalytics.track("purchase", {
                "gb_id": id,
                "currency": "INR",
                "value": parseInt(planAmount),
            });
h
rudderanalytics.track()
is not a async function. Can you explain your use case? like you are firing a track call then redirecting the user to a different page? Am I correct?
f
@high-zoo-17436 yes you are correct .
1
h
If the next page that you are redirecting the user also has Rudderstack JS SDK then you can use this API: https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-javascript-sdk/supported-api/#querystring-api