Configure custom events
You can configure the ContentView and Registration events for SPA and MPA channels. The following examples show configuring custom events in GTM and AA.
- Go to the Container and create a Custom HTML tag.
- Add the relevant code snippet as shown below.
Note:
In the code, you only need to insert the appropriate values in YOUR VALUES and CHANNEL TENANT ID. Do not make any other changes to the code snippet.
Registration event
var eventObj = {};
eventObj.eventCode = "ibmregistration";
eventObj.identifiers = [];
eventObj.attributes = [{ "name": "clientId", "value": "PUT YOUR VALUES", "type": "string" },
{ "name": "eventName", "value": "PUT YOUR VALUES", "type": "string" },
{ "name": "description", "value": "PUT YOUR VALUES", "type": "string" },
{ "name": "registrationDate", "value": "PUT YOUR VALUES", "type": "string" },
{ "name": "channelTenantId", "value": <<Put Channel Tenant ID>>, "type": "string" }]
ibm_ubx.sendEvent(eventObj, google_ubx.host, google_ubx.authKey, "GOOGLEANALYTICS", google_ubx.requestType);
ContentView event
var eventObj = {};
eventObj.eventCode = "ibmregistration";
eventObj.identifiers = [];
eventObj.attributes = [{ "name": "clientId", "value": "PUT YOUR VALUES", "type": "string" },
{ "name": "eventName", "value": "PUT YOUR VALUES", "type": "string" },
{ "name": "description", "value": "PUT YOUR VALUES", "type": "string" },
{ "name": "registrationDate", "value": "PUT YOUR VALUES", "type": "string" },
{ "name": "channelTenantId", "value": <variable v=Put Channel Tenant ID data="PUT CHANNEL TENANT ID" isdefault="true"></variable>, "type": "string" }]
ibm_ubx.sendEvent(eventObj, google_ubx.host, google_ubx.authKey, "GOOGLEANALYTICS", google_ubx.requestType);
Example code:
- Add a separate Custom HTML tag for each event.
- You should modify the values as per your attributes. The following code sample illustrates how to send events with required attributes.
- Add a trigger to the tag to call the event.
var eventObj = {};
eventObj.eventCode = "contentView";
eventObj.identifiers = [];
eventObj.attributes = [{ "name": "clientId", "value": "<variable v=Your values data="YOUR VALUES" isdefault="true"></variable>", "type": "string" },
{ "name": "eventName", "value": "<variable v=Your values data="YOUR VALUES" isdefault="true"></variable>", "type": "string" },
{ "name": "contentDescription", "value": "<variable v=Your values data="YOUR VALUES" isdefault="true"></variable>", "type": "string" },
{ "name": "siteId", "value": "<variable v=Your values data="YOUR VALUES" isdefault="true"></variable>", "type": "string" },
{ "name": "contentTimestamp", "value": "<variable v=Your values data="YOUR VALUES" isdefault="true"></variable>", "type": "string" },
{ "name": "elementId", "value": "<variable v=Your values data="YOUR VALUES" isdefault="true"></variable>", "type": "string" },
{ "name": "elementCategory", "<variable v=Your values data="YOUR VALUES" isdefault="true"></variable>": "Web Element", "type": "string" },
{ "name": "contentTotalLength", "<variable v=Your values data="YOUR VALUES" isdefault="true"></variable>": "2min", "type": "string" },
{ "name": "contentType", "value": "<variable v=Your values data="YOUR VALUES" isdefault="true"></variable>", "type": "string" },
{ "name": "channelTenantId", "value": "<variable v=Channel Tenant ID data="CHANNEL TENANT ID" isdefault="true"></variable>", "type": "string" }]
ibm_ubx.sendEvent(eventObj, google_ubx.host, google_ubx.authKey, "GOOGLEANALYTICS", google_ubx.requestType);
Registration event
- Go to the Launch Property and create a rule.
- Provide a name for the rule: Registration Event
- Add a core-click event on a specific element
- Add an Action and provide the following details:
- Extension: Core
- Action type: Custom Code
- Language: JavaScript
- Open Editor and add the following code.
- Map the
channelTenant
with theAdobe variable
using theAA- Set
variable action. - In the following code snippet, insert the appropriate values.
attributesMapper = [];
attributesMapper = [{"name":"clientId","value":"PUT YOUR VALUES","type":"string"},
{"name":"eventName","value":""<<Put Your Values>>"","type":"string"},
{"name":"description","value":""<<Put Your Values>>"","type":"string"},
{"name":"registrationDate","value” :"<<Put Your Values>>","type":"string"}];
attributesMapper.push({"adobeName":"ADOBE VARIABLE NAME", "ubxName":"channelTenantId", "type":"string"});
adobe_ubx.sendEventFromJSONPayload(s, identifiersMapper, "ibmregistration", attributesMapper);
- Click Save and keep changes.
- Save the rule and publish the changes.
ContentView event
- Go to the Launch Property and create a rule.
- Provide the rule name: ContentView Event
- Add a core-click event on a specific element.
- Add an Action and provide the following details:
- Extension: Core
- Action type: Custom Code
- Language: JavaScript
- Open Editor and add the following code.
- Map the
channelTenant
with theAdobe variable
using theAA- Set
variable action. - In the following code snippet, insert the appropriate values.
attributesMapper = [];
attributesMapper = [{"name":"clientId","value":"PUT YOUR VALUES","type":"string"},
{"name":"eventName","value":"PUT YOUR VALUES","type":"string"},
{"name":"contentDescription","value":"PUT YOUR VALUES","type":"string"},
{"name":"siteId","value":"PUT YOUR VALUES","type":"string"},
{"name":"contentTimestamp","value":”<<Put Your Values>>”,"type":"string"},
{"name":"elementId","value":"PUT YOUR VALUES","type":"string"},
{"name":"elementCategory","value":"PUT YOUR VALUES","type":"string"},
{"name":"contentTotalLength","value":"PUT YOUR VALUES","type":"string"}]
attributesMapper.push({"adobeName":"ADOBE VARIABLE NAME", "ubxName":"channelTenantId", "type":"string"});
adobe_ubx.sendEventFromJSONPayload(s, identifiersMapper, "ibmregistration", attributesMapper);
- Click Save and keep changes.
- Save the rule and publish the changes.
Updated over 2 years ago