resetState
- Topics:
- Identities
- Integrations
CREATED FOR:
- Developer
- User
- Admin
- Leader
This function is designed mainly for A4T customers to help solve issues related to working with IDs on single page sites/screens or apps.
Use cases
As an A4T customer who uses the ID service, you may want to use the visitor.resetState()
function when you need to:
- To pass a Supplemental Data ID (SDID), or any other ID, from one page or screen to another through a redirect. Normally, the ID service won’t pass this ID without this function.
- Use code that only updates specific sections of a page or app via Ajax calls and you want to track those actions. For example, say you have a page where clicking on an object only loads or changes a special section. In this case, the ID service can’t request a different ID unless the page is reloaded. However, with
visitor.resetState()
, you can request a new ID under these conditions.
See the code samples below.
Syntax
Syntax: visitor.resetState( *
state*);
Code samples
Your ID service implementation affects how you would use this function. Refer to the table below for examples.
Server-side implementation
A server-side implementation is for A4T customers with mixed server- and client-side implementations of Target, Analytics, and the ID service. If you’ve set up the ID service with this method all you need to do is add visitor.resetState()
to the page. Calls to the ID service will return a new ID and server state automatically.
Non-standard implementation (with ID)
If you’ve set up the ID service with a non-standard implementation, you need to configure a variable object to hold the SDID (or other IDs) you want to pass with visitor.resetState()
. As shown below, this would include your organization ID and the ID you want to pass. Your code could look similar to the following example.
//Instantiate server state variable
var serverState = {
"Insert Experience Cloud organization ID here": {
//Specify the SDID or other ID
supplementalDataIDCurrent: "1234",
supplementalDataIDCurrentConsumed: {
"payload:top-center": false
}
}
};
//Instantiate ID service
var visitor = Visitor.getInstance ("Insert Experience Cloud organization ID here", {
...
});
//Reset server state to pass the SDID
visitor.resetState(serverState);
Non-standard implementation (without passing an ID)
In this case, visitor.resetState()
can be used to generate a new ID. This can be useful in a single-page app when a user navigates to a new screen without refreshing the page and you need a new ID.
//Instantiate ID service
var visitor = Visitor.getInstance ("Insert Experience Cloud organization ID here", {
...
});
//Request a supplemental Data ID for consumer1 and consumer2:
var sdid1 = visitor.getSupplementalDataID("consumer1"); // sdid1: 1234
var sdid2 = visitor.getSupplementalDataID("consumer2"); // sdid2: 1234
//User navigates to a new screen in a single-page app, without refreshing the page.
//To reset the Supplemental Data ID internal, call resetState without passing any parameters.
//This way we will not be recycling the `1234` ID anymore. Instead Visitor will generate a new supplemental Data ID going forward.
visitor.resetState();
//Request a supplemental Data ID for consumer3 and consumer4:
var sdid1 = visitor.getSupplementalDataID("consumer3"); // sdid1: 5678
var sdid2 = visitor.getSupplementalDataID("consumer4"); // sdid2: 5678
Dynamic Tag Manager (DTM)
Currently, there is no DTM configuration path for visitor.resetState()
.
Experience Cloud Services
- Identity Service Help
- Overview
- Implementation
- Implementation methods
- Implementation guides
- Implement with Experience Platform tags
- Implement for Analytics
- Implement for Target
- Implement for Analytics and Audience Manager
- Implement for Analytics, Audience Manager, and Target
- Using the ID Service with A4T and a Server-side Implementation of Target
- Direct Integration with the ID Service
- Direct Integration Use Cases
- Test and verify the ID Service
- Opt-in Service
- ID Service API
- ID Service API Overview
- Configuration
- Configurations overview
- audienceManagerServer and audienceManagerServerSecure
- cookieDomain
- cookieLifetime
- disableIdSyncs
- disableThirdPartyCalls
- disableThirdPartyCookies
- idSyncAttachIframeOnWindowLoad
- idSyncContainerID
- idSyncSSLUseAkamai
- loadTimeout
- overwriteCrossDomainMCIDAndAID
- resetBeforeVersion
- sdidParamExpiry
- Secure and SameSite configurations
- secureCookie
- useCORSOnly
- whitelistParentDomain and whitelistIframeDomains
- Methods
- Methods
- appendSupplementalDataIDTo
- appendVisitorIDsTo (Cross-Domain Tracking)
- callTimeOut Methods
- ID Synchronization by URL or Data Source
- getInstance
- getAnalyticsVisitorID
- getCustomerIDs
- setCustomerIDs
- getMarketingCloudVisitorID
- getLocationHint
- getVisitorValues
- isClientSideMarketingCloudVisitorID
- resetState
- Reference
- Reference Overview
- Analytics Reference
- Analytics Reference Overview
- CNAME Implementation Overview
- Setting Analytics and Experience Cloud IDs
- Order of Operations for Analytics IDs
- ID Service Migration Decision Points
- ID Service Migration Scenarios
- Analytics and Identity Requests
- Server-side Implementation Mixed with JavaScript
- The ID Service Grace Period
- Google Chrome SameSite labelling changes
- Content Security Policies and the ID Service
- COPPA Support in the ID Service
- CORS Support in the ID Service
- Customer IDs and Authentication States
- ECID library methods in a Safari ITP world
- Identifying Unique Visitors
- Get Region and User IDs From the AMCV Cookie or the ID Service
- Requirements for the ID Service
- Video Heartbeat and the ID Service
- Data Workbench and the ID Service
- SHA256 Hashing Support for setCustomerIDs
- FAQs
- Release notes for ID Service
Connect with Experience League at Summit!
Get front-row access to top sessions, hands-on activities, and networking—wherever you are!
Learn more