Capture the Ruler Analytics Visitor ID
Accessing the Ruler Analytics Visitor ID (RAID)
Accessing the Ruler Analytics Visitor ID (RAID)
Ruler Analytics assigns a unique Visitor ID, also known as a RAID, to visitors on your website.
The RAID can be used as an identifier to associate website activity with an individual visitor or form submission. It can also be passed into your internal systems, such as your CRM, and used to associate offline customer data with Ruler reporting.
If you do not wish to capture or report on Personally Identifiable Information (PII), such as an email address, the RAID can provide an alternative identifier for connecting website activity with your internal data.
Before Starting
Ensure that the Main Ruler Analytics JavaScript is installed on your website.
You can find your unique Ruler Analytics tracking script in your account under Site Setup.
NoteThe Visitor ID is generated and made available by the Ruler tracking script. If the script has not loaded, the Visitor ID will not be available.
Accessing the Visitor ID
The Ruler Visitor ID is available on your website in two ways:
Option 1: Global JavaScript Variable
If the Ruler tracking tag is present and has loaded on your website, the Visitor ID is exposed through the global JavaScript variable:
RulerAnalyticsVisitorId
You can access the value using:
console.log(RulerAnalyticsVisitorId);This will return the Visitor ID for the current visitor when it is available.
Option 2: First-Party Cookie
The Visitor ID is also stored in a first-party cookie named:
__rasesh
You can retrieve the cookie value using JavaScript:
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
}
const rulerVisitorId = getCookie('__rasesh');
console.log(rulerVisitorId);Important Considerations
The Visitor ID may not be available immediately when the page loads.
The value will only be available once the Ruler tracking tag has loaded. It may also be unavailable if the visitor has not consented to, or has blocked, the relevant cookies.
For this reason, we recommend including fallback logic in any implementation that relies on the Visitor ID.
Your implementation should account for scenarios where:
- The Ruler tracking script has not loaded yet.
- The Visitor ID has not yet been generated.
- The visitor has declined or blocked the relevant cookies.
- The Visitor ID is otherwise unavailable.
Common Use Case: Adding the Visitor ID to a Form
One common use case is capturing the Ruler Visitor ID alongside a form submission.
This can be particularly useful when you do not want to collect PII, or where your existing form tracking makes it difficult to pass an email address or other identifying information to Ruler.
1. Add a Hidden Form Field
Add a hidden input field to your form:
<!-- Hidden form input field for Ruler Visitor ID -->
<input type="hidden" name="ruler_visitor_id" id="ruler_visitor_id">2. Populate the Field With the Visitor ID
You can then use JavaScript to populate the hidden field with the Ruler Visitor ID:
document.addEventListener('DOMContentLoaded', function () {
const visitorId = window.RulerAnalyticsVisitorId || getCookie('__rasesh');
const input = document.getElementById('ruler_visitor_id');
if (input && visitorId) {
input.value = visitorId;
}
});Your form submission will then contain the Visitor ID, which can be stored alongside the rest of your form data in your CRM or internal systems.
NoteThe steps above are for example purposes and each setup/form will differ and you should first consult your providers own documentation on their recommendations for adding in custom variables or hidden fields.
Using the Visitor ID With Offline CRM Data
The Visitor ID can be stored in your CRM alongside a lead or customer record.
When you subsequently upload offline CRM data to Ruler, the Visitor ID can be used as an identifier to help associate the offline conversion or revenue event with the relevant website activity.
This can be particularly useful when you want to connect online marketing activity with offline outcomes without relying on PII such as an email address.
Good to KnowThe Visitor ID is an identifier and should be handled in accordance with your organisation's privacy, consent, and data protection requirements. Using a Visitor ID does not remove your responsibility to ensure that your tracking and data-processing practices are appropriate for your use case.
Need Help?
If you need help accessing the Visitor ID, or using it with your CRM data, please reach out to a member of the Ruler team.
Updated 9 days ago