The RudderStack JavaScript SDK allows you to utilize our rudder-analytics.js
library to start sending data from your website to RudderStack. After integrating this SDK, you will also be able to connect to multiple destinations such as Amplitude, Google Analytics, and more, to send your event data.
NOTE: To quickly get up and running with setting up and using the RudderStack JavaScript SDK, please go through our quick start guide.
To integrate the RudderStack JavaScript SDK with your website, place either the minified or non-minified version of the code snippet in the <head>
section of your website.
<script>rudderanalytics=window.rudderanalytics=[];for(var methods=["load","page","track","identify","alias","group","ready","reset","getAnonymousId","setAnonymousId"],i=0;i<methods.length;i++){var method=methods[i];rudderanalytics[method]=function(a){return function(){rudderanalytics.push([a].concat(Array.prototype.slice.call(arguments)))}}(method)}rudderanalytics.load(<YOUR_WRITE_KEY>,<DATA_PLANE_URL>),rudderanalytics.page();</script><script src="https://cdn.rudderlabs.com/rudder-analytics.min.js"></script>
You can find your source write key and the data plane URL on your RudderStack dashboard.
<script>rudderanalytics = window.rudderanalytics = [];var methods = ["load","page","track","identify","alias","group","ready","reset","getAnonymousId","setAnonymousId"];for (var i = 0; i < methods.length; i++) {var method = methods[i];rudderanalytics[method] = function (methodName) {return function () {rudderanalytics.push([methodName].concat(Array.prototype.slice.call(arguments)));};}(method);}rudderanalytics.load(YOUR_WRITE_KEY, DATA_PLANE_URL);//For example,//rudderanalytics.load("1Qb1F3jSWv0eKFBPZcrM7ypgjVo", "http://localhost:8080");rudderanalytics.page();</script><script src="https://cdn.rudderlabs.com/v1/rudder-analytics.min.js"></script>
NOTE: The above code snippet will load rudder-analytics.js
on to your page synchronously. To load the SDK asynchronously to keep your page load time unaffected, use the following instead:
<script async src="https://cdn.rudderlabs.com/rudder-analytics.min.js"></script>
// Combining the initialization and the above async script together<script type="text/javascript">!function(){var e=window.rudderanalytics=window.rudderanalytics||[];e.methods=["load","page","track","identify","alias","group","ready","reset","getAnonymousId","setAnonymousId"],e.factory=function(t){return function(){var r=Array.prototype.slice.call(arguments);return r.unshift(t),e.push(r),e}};for(var t=0;t<e.methods.length;t++){var r=e.methods[t];e[r]=e.factory(r)}e.loadJS=function(e,t){var r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src="https://cdn.rudderlabs.com/v1/rudder-analytics.min.js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(r,a)},e.loadJS(),e.load(WRITE_KEY, DATA_PLANE_URL), e.page()}();</script>
The above code snippet does the following:
Creates an array to store the events until the analytics object is ready.
Stores a list of methods to replay them when the analytics object is ready. These methods include:
Method | Description |
| Loads |
| Records page views whenever a user visits a page |
| Keeps track of user actions and important events |
| Associates users and their traits or actions |
| Resets the |
Loads the analytics object with your write key.
Makes the page()
call to track the page view. It auto-captures properties such as path
, referrer
, search
, title
, and URL
. If you want to override them, use the call mentioned in the section JavaScript SDK APIs.
Although we recommend using the minified or non-minified snippet as mentioned above to use RudderStack SDK with your website, you can also use this NPM module to package RudderStack directly into your project.
To install, run the following command:
npm install rudder-sdk-js --save
This NPM module is only meant to be used for a browser installation. If you want to integrate RudderStack with your Node.js applications, please refer to the RudderStack Node.js repository.
Important: Since the module exports the related APIs on an already-defined object combined with the Node.js module caching, you should run the below code snippet only once and use the exported object throughout your project.
import * as rudderanalytics from "rudder-sdk-js"rudderanalytics.ready(() => {console.log("we are all set!!!")})rudderanalytics.load(WRITE_KEY, DATA_PLANE_URL)export { rudderanalytics }
You can also do so with ES5, using the require
method, as shown:
var rudderanalytics = require("rudder-sdk-js")rudderanalytics.load(WRITE_KEY, DATA_PLANE_URL)exports.rudderanalytics = rudderanalytics
Please refer to the following projects for a detailed walk-through of the above steps:
The related APIs exported by the module are:
load
ready
identify
alias
page
track
group
reset
getAnonymousId
setAnonymousId
RudderStack’s JavaScript SDK makes it very easy for you to send your event data to any destination without having to implement a new API every single time.
Let us take a look at some of the key methods in this section:
The load()
method loads the rudderanalytics.js
file with your write key.
The load()
method is defined as follows:
rudderanalytics.load(<YOUR_WRITE_KEY>, <DATA_PLANE_URL>, options);
NOTE: You need to replace <YOUR_WRITE_KEY>
with the write key in the RudderStack Control Plane and <DATA_PLANE_URL>
with the URL of the RudderStack Server.
The options
parameter in the above load
call looks like the following:
{logLevel: "DEBUG" | "INFO" | "WARN",integrations: IntegrationOpts,configUrl: string, // defaults to https://api.rudderlabs.comqueueOptions: QueueOpts,loadIntegration: boolean // defaults to true.}
It includes the following details:
Parameter | Type | Description |
| String | Options include |
| - | Refer to |
| String | Defaults to |
| - | Refer to |
| Boolean | Defaults to |
The structure of IntegrationOpts
looks like the following:
IntegrationOpts {All: boolean, // default true<Destination1>: boolean,<Destination2>: boolean,...}
Parameter | Type | Description |
| Boolean | Corresponds to all the destinations to which the event has to be sent. Default is set to |
| Boolean | Specific destination to which the event is to be sent or not sent, depending on the boolean value assigned to it. |
More information on the Load IntegrationOpts
option can be found here:
The structure of QueueOpts
looks like the following:
QueueOpts {maxRetryDelay: 360000, // Upper cap on maximum delay for an eventminRetryDelay: 1000, // minimum delay before sending an eventbackoffFactor: 2, // exponentional basemaxAttempts: 10, // max attemptsmaxItems: 100, // max number of events in storage}
Parameter | Description |
| Corresponds to the upper limit on the maximum delay for an event. Default value is set as 36000ms. |
| Corresponds to the minimum delay expected before sending an event. Default value is set to 1000ms. |
| Refers to the exponential base. Default value is set to 2. |
| Refers to the maximum attempts to send the event to the destination. Default value is set to 10. |
| Refers to the maximum number of events kept in the storage. Default value is set to 100. |
If you are self-hosting the Control Plane, your load
call will look like the following:
rudderanalytics.load(WRITE_KEY, DATA_PLANE_URL, {configUrl: CONTROL_PLANE_URL});
RudderStack allows you to load selective destinations as specified by you and disable sending events to the remaining destinations. You can specify these destinations through the load
call, as shown:
rudderanalytics.load(WRITE_KEY, DATA_PLANE_URL, {integrations: { All: false, destination_name: true },});
For more information, please check the How to Filter Selective Destinations section.
This method allows you to link the users and their actions to a specific userid
. You can also add additional information as traits
to a user. Once you set the identify
information to the user, those will be passed to the successive track
or page
calls. To reset the user identification, you can use the reset
method.
The identify()
method definition is as follows:
rudderanalytics.identify([userid], [traits], [options], [callback]);
A sample example of how to use the identify()
method is as shown:
rudderanalytics.identify("userId",{ email: "name@domain.com" },{page: {path: "",referrer: "",search: "",title: "",url: "",}},() => {console.log("in identify call");});
In the above example, information such as the userid
and email along with contextual information such as IP address, etc. is captured.
The above identify
call has the following parameters:
Parameter | Description |
| This string defines the database ID of the user. If provided, this optional argument will be sent to destinations as the user ID instead of an anonymous ID |
| This optional dictionary contains the traits or properties associated with a |
| This dictionary is also optional, and provides information such as context, integrations, and |
| This function gets executed after successful execution of the |
The options parameter in the identify
call looks like the following:
{integrations: IntegrationOpts,anonymousId: string,originalTimestamp: ISO 8601 date string,<other keys>: <value> // merged with event's contextual information}
Parameter | Type | Description |
| - | Refer to |
| String | Overrides the current event |
| ISO 8601 date string | Overrides the current event |
| - | Merged with the event's contextual information |
The structure of IntegrationOpts
looks like the following:
IntegrationOpts {All: boolean, // default true<Destination1>: boolean,<Destination2>: boolean,...}
Parameter | Type | Description |
| Boolean | Corresponds to all the destinations to which the event has to be sent. Default is set to |
| Boolean | Specific destination to which the event is to be sent or not sent, depending on the boolean value assigned to it. |
More information on the IntegrationOpts
option can be found here:
NOTE: The anonymousId
is a UUID (Universally Unique Identifier) generated to uniquely identify the user. Also, if it is provided by the user using the setAnonymousId
method, the user-specified anonymousId
overrides the SDK-generated one.
There is no need to callidentify()
for anonymous visitors to your website. Such visitors are automatically assigned an anonymousId
The JavaScript SDK generates one unique anonymousId
, stores it in a cookie named rl_anonymous_id
, and attaches to every subsequent event. This helps in identifying the users from other sites that hosted under a sub-domain.
As an example, if you include the RudderStack JavaScript SDK in both admin.samplewebsite.com and app.samplewebsite.com, the SDK will store the cookie in the top-level domain samplewebsite.com.
If you identify a user with your application's unique identifier like email, database ID etc. RudderStack stores this ID in a cookie named rl_user_id
and attaches to every event.
There are two options that you can use to identify users when using the JavaScript SDK:
There can be scenarios where you may want to provide your own anonymousID
instead of an auto-generated ID by the SDK. To do so, you can provide the anonymousId
in the options
parameter of the identify
call, as mentioned above. This will send the value provided by you in the anonymousId
key of the event.
All other events will haveanonymousId
from the one persisted in the cookie, except this event where you override the options.
An example of this approach is as shown in the code snippet below:
rudderanalytics.identify("12345",{ email: "name@domain.com" },{anonymousId: "my-anonymous-id",},() => {console.log("in identify call");});js
You can also override the anonymousId
for all the future events using the rudderAnanlytics.setAnonymousId
method.
An example of this is shown in the code snippet below:
rudderanalytics.setAnonymousId("my-anonymous-id");// All event payloads will have the anonymousId key set "my-anonymous-id".rudderanalytics.identify("userId", { email1: "name@domain.com" }, () => {console.log("in identify call");});
You can call the following method to parse the AMP Linker ID and set the anonymousId
as shown:
setAnonymousId(null, "<version>*<checkSum>*<idName1>*<idValue1>*<idName2>*<idValue2>...")
Here, the second parameter is the AMP Linker ID format in accordance with the specified structure. For the links decorated with the RudderStack Linker parameter, the <idName1>
value will be rs_amp_id
.
Calling the above method will parse the Linker ID and set the anonymousId
as the value of the rs_amp_id
key.
To identify new users in scenarios like a new login, you can take one of the following approaches:
Call the identify
API with a new userid
. RudderStack will reset all cookies related to the user for userid
and user-traits
and update them with the new values provided by you.
The anonymousId
will remain unchanged in this case. It will be the value that you set explicitly using setAnonymousId
, or the auto-generated value set by the SDK while loading.
Explicitly call rudderanalytics.reset()
and then call identify
. It has the same effect as described above.
For updating the traits of a user, you can call identify with the same userid
multiple times with new traits. All the traits for that user keep on getting appended/modified.
Calling reset()
or identifying with a new userId
with new traits will reset the earlier traits and update them with the new values, as shown:
rudderanalytics.identify("userId",{ email1: "name@domain.com" },() => { console.log("in identify call"); });rudderanalytics.identify("userId",{ email2: "name@domain.com" },() => { console.log("in identify call"); });// both email1 and email2 with be sent in the identify payload// for the second call.
This method lets you record information about the web page being viewed by the user. This includes page views, category, and other relevant information about the page.
The page()
method definition is as follows:
rudderanalytics.page([category],[name],[properties],[options],[callback]);
A sample example of how to use the page()
method is as shown:
rudderanalytics.page("Cart","Cart Viewed",{path: "",referrer: "",search: "",title: "",url: "",},() => {console.log("in page call");});
In the above example, the page()
method captures information such as the page category and page name. It also captures contextual information such as IP address and the ID of the user.
The above code snippet has the following parameters:
Parameter | Description |
| An optional string that defines the category of the page |
| An optional string that defines the name of the page |
| An optional dictionary that defines the properties of the page. These properties are auto-captured by the page |
| An optional dictionary that provides information such as context, integrations, |
| This function gets executed after successful execution of the |
The options
parameter in the page
call looks like the following:
{integrations: IntegrationOpts,anonymousId: string,originalTimestamp: ISO 8601 date string,<other keys>: <value> // merged with event's contextual information}
Parameter | Type | Description |
| - | Refer to |
| String | Overrides the current event |
| ISO 8601 date string | Overrides the current event |
| - | Merged with the event's contextual information |
The structure of IntegrationOpts
looks like the following:
IntegrationOpts {All: boolean, // default true<Destination1>: boolean,<Destination2>: boolean,...}
Parameter | Type | Description |
| Boolean | Corresponds to all the destinations to which the event has to be sent. Default is set to |
| Boolean | Specific destination to which the event is to be sent or not sent, depending on the boolean value assigned to it. |
More information on the IntegrationOpts
option can be found here:
This method allows you to track any actions that your users might perform. Each of these actions is commonly referred to as an event.
The track()
method definition is as follows:
rudderanalytics.track(event,[properties],[options],[callback]);
A sample example of how to use the track()
method is as shown:
rudderanalytics.track("test track event GA3",{revenue: 30,currency: 'USD' ,user_actual_id: 12345},() => {console.log("in track call");});
In the above example, the method tracks the event test track event GA3
, information such as the revenue, currently, user ID, and other contextual information such as IP address.
The above code snippet has the following parameters:
Parameter | Description |
| A string that captures the name of the event that is being tracked |
| An optional dictionary that tracks the properties of the event |
| An optional dictionary of information such as context, integrations, etc. Specific user traits can be provided as the context as well |
| This function gets executed after successful execution of the |
The options
parameter in the track
call looks like the following:
{integrations: IntegrationOpts,anonymousId: string,originalTimestamp: ISO 8601 date string,<other keys>: <value> // merged with event's contextual information}
Parameter | Type | Description |
| - | Refer to |
| String | Overrides the current event |
| ISO 8601 date string | Overrides the current event |
| - | Merged with the event's contextual information |
The structure of IntegrationOpts
looks like the following:
IntegrationOpts {All: boolean, // default true<Destination1>: boolean,<Destination2>: boolean,...}
Parameter | Type | Description |
| Boolean | Corresponds to all the destinations to which the event has to be sent. Default is set to |
| Boolean | Specific destination to which the event is to be sent or not sent, depending on the boolean value assigned to it. |
More information on the IntegrationOpts
option can be found here:
Many destination platforms need an explicit alias
call for mapping the already identified users to a new identifier that you may want to use, to track the users in the future. The RudderStack alias
API allows you to implement this functionality.
Simply put, the alias
call associates the user with a new identification.
The format of an alias
call is as shown:
rudderanalytics.alias("to", "from", options, callback);
The above alias
call has the following parameters:
Parameter | Presence | Description |
| Required | Denotes the new identifier |
| Optional | Denotes the old identifier which will be an alias for the |
| Optional | This dictionary provides additional context to the event payload. |
| Optional | This function gets executed after successful execution of the |
The options
parameter in the alias
call looks like the following:
{integrations: IntegrationOpts,anonymousId: string,originalTimestamp: ISO 8601 date string,<other keys>: <value> // merged with event's contextual information}
Parameter | Type | Description |
| - | Refer to |
| String | Overrides the current event |
| ISO 8601 date string | Overrides the current event |
| - | Merged with the event's contextual information |
The structure of IntegrationOpts
looks like the following:
IntegrationOpts {All: boolean, // default true<Destination1>: boolean,<Destination2>: boolean,...}
Parameter | Type | Description |
| Boolean | Corresponds to all the destinations to which the event has to be sent. Default is set to |
| Boolean | Specific destination to which the event is to be sent or not sent, depending on the boolean value assigned to it. |
More information on the IntegrationOpts
option can be found here:
A sample example of how to use the alias()
method is as shown:
rudderanalytics.alias("test_new_id");
The group
call associates a user to a specific organization.
The format of a group call is as shown:
rudderanalytics.group("groupId", traits, options, callback);
The above group
call has the following parameters:
Parameter | Presence | Description |
| Required | Denotes the group identifier to which the traits are to be modified or added. RudderStack will call the destination APIs to attach the currently identified user to this group. |
| Optional | Denotes the traits of the group. RudderStack will pass these traits to the destination to enhance the group properties. |
| Optional | This dictionary provides additional context to the event payload. |
| Optional | This function gets executed after successful execution of the |
The options
parameter in the group
call looks like the following:
{integrations: IntegrationOpts,anonymousId: string,originalTimestamp: ISO 8601 date string,<other keys>: <value> // merged with event's contextual information}
Parameter | Type | Description |
| - | Refer to |
| String | Overrides the current event |
| ISO 8601 date string | Overrides the current event |
| - | This info is merged with the event's contextual information |
The structure of IntegrationOpts
looks like the following:
IntegrationOpts {All: boolean, // default true<Destination1>: boolean,<Destination2>: boolean,...}
Parameter | Type | Description |
| Boolean | Corresponds to all the destinations to which the event has to be sent. Default is set to |
| Boolean | Specific destination to which the event is to be sent or not sent, depending on the boolean value assigned to it. |
More information on the IntegrationOpts
option can be found here:
An example of how to use the group
call is as shown below:
rudderanalytics.group("sample_group_id", {name: "CompanyA",location: "USA",});
This method resets the userid
and the associated traits and properties of that specific user.
The reset()
method can be used as shown:
rudderanalytics.reset();
NOTE: The reset()
method only clears the cookies and local storage set by RudderStack, and not the information stored by the integrated destinations. To completely clear the user session, please refer to the documentation provided by those respective tools.
RudderStack allows you to send your event data only to a few intended destinations by filtering out the rest. You can do so by passing an integrations object in the options parameter of the identify()
, page()
, and track()
methods.
The following is an example of how to send a sample message only to Google Analytics and Intercom:
rudderanalytics.identify("samplename",{email: "name@email.org",name: "Samplename",},{integrations: {All: false,"Google Analytics": true,"Intercom": true,},});
The line All: false
instructs RudderStack not to send the event data to any destinations by default, unless they are explicitly listed as true
in the subsequent lines.
You can also disable sending event data to certain destinations. In this case, the event data is sent to all the other destinations except the specified ones. An example of this is as shown:
rudderanalytics.identify("samplename",{email: "name@email.org",name: "Samplename",},{integrations: {"Google Analytics": false,"Intercom": false,},});
As seen in the above code snippet, RudderStack will send the event data to all the destinations except Google Analytics and Intercom.
NOTE: Unless explicitly defined otherwise, 'All'
is always set to true
. This means that sending events to all destinations is enabled by default.
You can also choose to load selective destinations by modifying the load
method to take a third argument. You can pass anintegrations
dictionary containing the destination names in the format specified above. RudderStack loads only those destinations that are marked as enabled with the boolean value true
.
RudderStack supports the following destination names for sending the event data through the load
method as described above:
Destination | Supported Common Names |
Google Analytics |
|
|
|
|
|
Google Ads |
|
|
|
|
|
Braze |
|
|
|
Chartbeat |
|
|
|
Customer.io |
|
|
|
Facebook Pixel |
|
|
|
|
|
Google Tag Manager |
|
|
|
Hotjar |
|
|
|
Hubspot |
|
|
|
Intercom |
|
|
|
Keen.IO |
|
|
|
|
|
Kissmetrics |
|
|
|
Lotame |
|
|
|
VWO |
|
|
|
Amplitude |
|
Mixpanel |
|
Facebook App Events |
|
Amazon S3 |
|
MinIO |
|
Salesforce |
|
Autopilot |
|
Heap.io |
|
Mailchimp |
|
Redshift |
|
BigQuery |
|
Google Cloud Storage |
|
Azure Blob Storage |
|
Branch Metrics |
|
Kochava |
|
Leanplum |
|
Slack |
|
Zendesk |
|
AWS Personalize |
|
Amazon Kinesis |
|
A sample RudderStack load method with integration names passed as arguments will look like the following snippet:
rudderanalytics.load(WRITE_KEY, DATA_PLANE_URL, {integrations: { All: false, destination_name: true },});
Where <destination name>
is the name of the destination as per the above list of common names.
An example of the load
method is as shown:
rudderanalytics.load(YOUR_WRITE_KEY, DATA_PLANE_URL, {integrations: { All: false, "Google Analytics": true, Intercom: true },});
As seen from the example above, three arguments are now passed in the load
method:
writekey
<DATA_PLANE_URL>
The integrations
dictionary containing Google Analytics
and Intercom
as the destination names
RudderStack gives you the option to automatically capture certain event-specific and user-specific data, based on the type of the event.
In this section, we cover two specific dictionaries, within the options
argument, which is included in the identify()
, page()
, and track()
methods.
A context is a dictionary of additional information about a particular data, such as a user’s IP address.
NOTE: A context is a complete and specific piece of information. Any other information provided outside of this specification is ignored.
A trait is an optional dictionary included within context
, which specifies the unique traits of the user. This is a very useful field for linking information of a user from a previously made identify()
call to a track()
or page()
event.
In order to better understand how contexts and traits work, let us look at the following identify
event:
rudderanalytics.identify("userId", {plan: "Paid, Premium",email: "name@surname.org",});
The trait in the above event is plan
. If you wish to include this trait in a subsequent track()
or page()
event that is triggered by the user, you can establish the association by passing this trait into context.traits
as shown:
rudderanalytics.track("Subscribed",{campaign: "Subscribe",},{traits: {plan: "Paid, Premium",},});
The above code snippet will append plan
as a trait to the track event.The trait email
will not be appended, as it was not specified in the context.traits
field.
RudderStack's Querystring API allows you to trigger track
, identify
calls using the query parameters.
You may use the below parameters as a query string parameters and trigger the corresponding call.
Parameter | Action |
| Makes a |
| Makes a |
| Makes a |
| If |
| If |
As an example, if you pass the following parameters in the URL as shown:
http://hostname.com/?ajs_uid=12345&ajs_event=test%20event&ajs_aid=abcde&ajs_prop_testProp=prop1&ajs_trait_name=Firstname+Lastname
The following SDK calls will be triggered:
rudderanalytics.identify("userId", {name: "Firstname Lastname"});rudderanalytics.track("test event", {testProp: "prop1"});rudderanalytics.setAnonymousId("anonymousId");
RudderStack's JavaScript SDK provides a way to send a page view containing relevant markers on whether a page is ad-blocked. You can analyze this data to find what percent of your site's page views are affected by ad-blockers.
To send an ad-blocked page view, load the SDK as follows:
rudderanalytics.load(WRITE_KEY, DATA_PLANE_URL, {sendAdblockPage: true,sendAdblockPageOptions: { integrations: { All: false, Amplitude: true } },});
Some of the properties in the snippet above are:
sendAdblockPage
: Enables the JavaScript SDK to make a call to load the Google AdSense library. If RudderStack fails to load this library, it concludes that an ad blocker is enabled on the page.
Since most ad blockers block the request to the Google AdSense servers, this is assumed as a good measure to detect ad-blocked pages.
sendAdblockPageOptions
: The RudderStack SDK will make an implicit page
call about the ad-blocked pages if sendAdblockPage
is set to true
. With sendAdblockPageOptions
, you can provide the destinations to which you want to forward this page
call.
The implicit page
call semantics is as follows:
rudderanalytics.page("RudderJS-Initiated", "ad-block page request", {path: "/ad-blocked",title:"error in script loading:: src:: http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js id:: ad-block",});
This section provides solutions to some of the commonly faced issues while using the RudderStack JavaScript SDK on your website.
Simply put, the Data Plane URL is used to connect to the RudderStack backend for processing and routing your events.
To get the Data Plane URL: **
If you're using the open-source version of RudderStack, you are required to set up your own data plane by installing and setting up RudderStack in your preferred dev environment.
If you're using the enterprise version of RudderStack, please contact us for the data plane URL with the email ID used to sign up for RudderStack.
In order to load analytics.js
, simply copy the minified or non-minified version of the code snippet provided in the Installing the RudderStack JavaScript SDK section.
To check if it has loaded correctly, open the JavaScript console in your browser:
Safari: Ctrl+Alt+I
(Windows) or Command+Option+I
(Mac) and go to the Console
tab
Chrome: Ctrl+Shift+J
(Windows) or Command+Option+J
(Mac)
Firefox: Ctrl+Shift+K
(Windows) or Command+Option+K
(Mac) and select the Console
tab
Internet Explorer: Press F12
and go to the Console
tab
In the console, run rudderanalytics
. If it returns an object as shown in the following code snippet, it means that the rudderanalytics.js
file has loaded successfully:
{Integrations: Object, _integrations: Object, _readied: true, _timeout: 300, _user: n_}
If it gives you an undefined
error, you might want to verify if the setting up procedure was correctly followed. Our Quick Start Guide may be able to help you get up and running.
Yes, it is important that you ensure no ad-blockers are running on your browser, as they restrict therudderanalytics.js
script from executing and storing user information in the browser.
No, it is not possible to load multiple instances of rudderanalytics.js
, as it is bound to exceed the maximum stack call size and give you an error.
To check if data is being transmitted to the specified destinations, go to the Network
tab of your JavaScript console on your browser.
NOTE: If the outbound request is not being shown, check if you have installed and set up the RudderStack JavaScript SDK correctly, or if ad-blockers are enabled on your browser.
The size limit on requests is 32 KB per message.
Yes, you can. Refer to the How to Filter Selective Destinations to Send Your Event Data section above to see how to do this.
An Anonymous ID is an auto-generated UUID (Universally Unique Identifier) that gets assigned to each unique visitor to your website.
To retrieve the anonymous ID of any visitor, simply call the following:
rudderanalytics.getAnonymousId();
NOTE: In case the anonymousId
value is null, calling the above function will lead to automatically setting a new anonymousId
.
To know more about the RudderStack JavaScript SDK or to see it in action, you can contact us or see the SDK in action. You can also talk to us on our Slack channel.
In case you come across any issues while using this SDK, please feel free to submit them on our GitHub issues page.