Expand my Community achievements bar.

SOLVED

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

Avatar

Level 1

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);

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

@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-t...

 

View solution in original post

1 Reply

Avatar

Correct answer by
Employee Advisor

@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-t...