This guide walks you through the steps to self-host the RudderStack JavaScript SDK and also covers different scenarios based on your directory structure.
Download the required device mode destination SDK file (<dest_name>.min.js) and its corresponding source map file (<dest_name>.min.js.map) from RudderStack CDN.
Downloading and hosting the source map files (rudder-analytics.min.js.map or <dest_name>.min.js.map) is optional but recommended to help in troubleshooting.
Move the files downloaded in the above steps in the following directory structure:
If you have a specific use-case where you need to follow a directory structure different than the one recommended above, follow the steps 1 and 2, and proceed with one of the below depending on your directory structure:
If your JavaScript SDK file name is rudder-analytics.min.js, but the destination SDKs are not located next to it under the js-integrations directory, add the following script tag in your website:
<script>// rudderanalytics object initialization
// provide the location of the destination SDKs in the load options
rudderanalytics.load(WRITE_KEY,DATA_PLANE_URL,{destSDKBaseURL:"https://<subdomain>.<yourdomain>.com/<path-to-integration-sdks-directory>"});// ...
</script><scriptsrc="https://<subdomain>.<yourdomain>.com/<path-to-sdk-base-directory>/rudder-analytics.min.js"></script>
If your JavaScript SDK file name is notrudder-analytics.min.js, and the destination SDKs are not located under the js-integrations directory, add the following script tag in your website:
This option is recommended, as providing a custom name for the core JavaScript SDK file (instead of rudder-analytics.min.js) can help overcome the ad-blockers, if any.
<script>// rudderanalytics object initialization
// provide the location of the destination SDKs in the load options
rudderanalytics.load(WRITE_KEY,DATA_PLANE_URL,{destSDKBaseURL:"https://<subdomain>.<yourdomain>.com/<path-to-integration-sdks-directory>"});// ...
</script><scriptsrc="https://<subdomain>.<yourdomain>.com/<path-to-custom-sdk-file>/<custom-sdk-file-name.js>"></script>
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.