There are various hooks available within the personalization lifecycle to allow you to attach logic to these hook points for automation. To use them you need to create functions matching the name a signature of the hook function and the code is called at the appropriate time, for example, when a slot has loaded.
The hooks you can use are as follows:
Before slot load
Triggers
Once for each Slot, after the data has been retrieved, before the page is updated.
Note: This hook can also be used to alter the html before it is added to the document by replacing the html attribute.
Hook function
window.frBeforeSlotLoad(slotID, data)
Parameters
Parameter | Type | Description |
---|---|---|
slotID | string | The ID of the Slot currently being processed |
data | object | The data generated by the server for the current Slot |
Example data value:
{
"html": "<h2>Hello World</h2>",
"css": null,
"js": null,
"var": {}, // Optional variables passed back from the server
meta: {
"tmsb": "SmartBlock ID",
"tmsl": "Slot ID"
"tmrl": "Rule ID"
"tmcs": "Content ID"
}
}
Example
function frBeforeSlotLoad(slotID,data) {
console.log("Hook: BeforeSlotLoad fired",slotID,data);
}
Return value
Boolean - If true, the slot is added to the page as normal. If false, the slot has not been added to the page.
On slot load
Triggers
Once for each slot, after the page has updated.
Note: This hook can also be used to alter the html before it is added to the document by replacing the html attribute.
Hook function
window.frOnSlotLoad(slotLoaded, slotID, data)
Parameters
Parameter | Type | Description |
---|---|---|
slotLoaded | boolean | Indicates whether the slot was added to the page or not |
slotID | string | The ID of the Slot currently being processed |
data | object | The data generated by the server for the current Slot |
Example data value:
{
"html": "<h2>Hello World</h2>",
"css": null,
"js": null,
"var": {}, // Optional variables passed back from the server
meta: {
"tmsb": "SmartBlock ID",
"tmsl": "Slot ID"
"tmrl": "Rule ID"
"tmcs": "Content ID"
}
}
Example
function frOnSlotLoad(slotLoaded, slotID, data) {
console.log("Hook: OnSlotLoad fired", slotID, slotLoaded, data);
}
Return value
None