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.

  1. Go to the Container and create a Custom HTML tag.
  2. 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": &lt;variable v=Put Channel Tenant ID data="PUT CHANNEL TENANT ID" isdefault="true"&gt;&lt;/variable&gt;, "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": "&lt;variable v=Your values data="YOUR VALUES" isdefault="true"&gt;&lt;/variable&gt;", "type": "string" }, { "name": "eventName", "value": "&lt;variable v=Your values data="YOUR VALUES" isdefault="true"&gt;&lt;/variable&gt;", "type": "string" }, { "name": "contentDescription", "value": "&lt;variable v=Your values data="YOUR VALUES" isdefault="true"&gt;&lt;/variable&gt;", "type": "string" }, { "name": "siteId", "value": "&lt;variable v=Your values data="YOUR VALUES" isdefault="true"&gt;&lt;/variable&gt;", "type": "string" }, { "name": "contentTimestamp", "value": "&lt;variable v=Your values data="YOUR VALUES" isdefault="true"&gt;&lt;/variable&gt;", "type": "string" }, { "name": "elementId", "value": "&lt;variable v=Your values data="YOUR VALUES" isdefault="true"&gt;&lt;/variable&gt;", "type": "string" }, { "name": "elementCategory", "&lt;variable v=Your values data="YOUR VALUES" isdefault="true"&gt;&lt;/variable&gt;": "Web Element", "type": "string" }, { "name": "contentTotalLength", "&lt;variable v=Your values data="YOUR VALUES" isdefault="true"&gt;&lt;/variable&gt;": "2min", "type": "string" }, { "name": "contentType", "value": "&lt;variable v=Your values data="YOUR VALUES" isdefault="true"&gt;&lt;/variable&gt;", "type": "string" }, { "name": "channelTenantId", "value": "&lt;variable v=Channel Tenant ID data="CHANNEL TENANT ID" isdefault="true"&gt;&lt;/variable&gt;", "type": "string" }] ibm_ubx.sendEvent(eventObj, google_ubx.host, google_ubx.authKey, "GOOGLEANALYTICS", google_ubx.requestType);

Registration event

  1. Go to the Launch Property and create a rule.
  2. Provide a name for the rule: Registration Event
  3. Add a core-click event on a specific element
  4. Add an Action and provide the following details:
    • Extension: Core
    • Action type: Custom Code
    • Language: JavaScript
  5. Open Editor and add the following code.
  6. Map the channelTenant with the Adobe variable using the AA- Set variable action.
  7. 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);
  1. Click Save and keep changes.
  2. Save the rule and publish the changes.

ContentView event

  1. Go to the Launch Property and create a rule.
  2. Provide the rule name: ContentView Event
  3. Add a core-click event on a specific element.
  4. Add an Action and provide the following details:
    • Extension: Core
    • Action type: Custom Code
    • Language: JavaScript
  5. Open Editor and add the following code.
  6. Map the channelTenant with the Adobe variable using the AA- Set variable action.
  7. 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);
  1. Click Save and keep changes.
  2. Save the rule and publish the changes.