Setting up Factors Data Layer
Place the Factors Javascript Website SDK on your website. Refer screenshot.
Enable data-layer feature on Factors app under Settings > Integrations > Javascript SDK > General Settings. (Raise a request to enable it, if you are unable to find it).
Everytime when a user visits your website, Factors Website SDK will add a global window variable called window.FactorsDataLayer with all the available attributes. Refer screenshot.
Currently available attributes
Is there a way for salespeak to send an event when a chat happens on salespeak - to factors?
Name: segments
Description: List of Factors Segments which the user is part of.
Data Type: List of JSON
Sample: [ { name: “Visits From U.S”, “id”: “123e4567-e89b-12d3-a456-426614174000” } ]
Name: ip_derived_info
Description: List of Factors defined properties derived from IP of the caller
Data Type: JSON
Sample: {
"company_employee_range":"10000+",
"company_industry":"IT Services",
"company_naics_code":"54",
"company_sic_code":"1",
"company_sector":"Industrials",
"company_sub_industry":"Design",
"company_annual_revenue_range":""
}
Connecting Factors Data Layer with Optimizely
Place the Optimizely SDK on your website (zaius). Refer screenshot.
Place the below script to pass the attributes from Factors Data Layer to Optimizely.
Below script forwards segments (user attribute from Factors Data Layer) to Optimizely. Similarly other attributes can be passed based on requirement.
<script>
var waitForObjects = (objects, iterator, callback) => {
if (iterator == 0) return;
var objectsToCheck = objects.length;
objects.forEach((object) => {
if (window[object]) {
objectsToCheck--;
}
});
if (objectsToCheck > 0) {
setTimeout(() => {
waitForObjects(objects, iterator - 1, callback);
}, 1000);
} else {
callback();
}
};
var injectFactorsData = () => {
if (
window.FactorsDataLayer.segments &&
window.FactorsDataLayer.segments.length > 0
) {
var segments = window.FactorsDataLayer.segments.map((seg) => seg.name);
var segmentNamesString = segments.join(', ');
zaius.customer({
factors_segments: segmentNamesString
});
}
};
waitForObjects(['FactorsDataLayer', 'zaius'], 10, injectFactorsData);
</script>
