Context Hub not able to call/called JavaScript function from page where targeting is configured. | Community
Skip to main content
anuragc21667703
November 11, 2022
Solved

Context Hub not able to call/called JavaScript function from page where targeting is configured.

  • November 11, 2022
  • 1 reply
  • 639 views

I have created a segment and added script Reference configured my custom script into it.

When referring to this segment to target on a page. Script is not executing on page so targeted content doesn't change. Do we need to define something specific in the script for execution.

 

Script code:

 

ContextHub.console.log(ContextHub.Shared.timestamp(), '[loading] contexthub.getURLInfo -getURLInfo.js');

(function($) {
'use strict';

var getURLInfo = function() {

var href = ContextHub.Utils.Persistence.defaultConfig.window.location.href;
var search = ContextHub.Utils.Persistence.defaultConfig.window.location.search;
console.log('href---' + href);
return href.includes('test');
};

/* register function */
ContextHub.SegmentEngine.ScriptManager.register('getURLInfo', getURLInfo);

})(ContextHubJQ);

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by krati_garg

@anuragc21667703 It is not clear from above snippet, how it is not clear how are you assigning Cloud Config, Segment Path and Context Hub path to your Site Page.

Please follow below tutorial for setting up Context Hub
https://experienceleague.adobe.com/docs/experience-manager-learn/sites/personalization/context-hub-technical-video-setup.html?lang=en

 

1 reply

krati_garg
Adobe Employee
krati_gargAdobe EmployeeAccepted solution
Adobe Employee
November 13, 2022

@anuragc21667703 It is not clear from above snippet, how it is not clear how are you assigning Cloud Config, Segment Path and Context Hub path to your Site Page.

Please follow below tutorial for setting up Context Hub
https://experienceleague.adobe.com/docs/experience-manager-learn/sites/personalization/context-hub-technical-video-setup.html?lang=en