Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards

How to test personalisation in AEM ContextHub based on Geolocation, URL Parameters, and User Behaviour?

Avatar

Level 2

Hi Community,

 

We’ve recently enabled ContextHub on our AEM instance as part of stakeholder request.

 

We plan to use ContextHub for rule-based personalisation in the following ways:

1. Geolocation-based targeting
2. URL parameters
3. User behaviour: e.g., first time users, returning visitors.

 

Could you please guide on:

How to set up and test these personalisations in AEM using ContextHub?

Any tips for verifying that rules (especially geolocation and URL-based) are being picked up correctly?

 

Appreciate any best practices or examples!

 

Thanks in advance,

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

2 Replies

Avatar

Community Advisor

Hi @GauravDu1 ,

1. Geolocation-based targeting

Setup

  • In ContextHub, make sure the Geolocation store is enabled (/etc/cloudsettings/default/contexthub)

  • This store uses IP-based location via browser APIs or external services

Create a Segment

  1. Go to Personalization → Segments

  2. Create a new segment with:

    • Store: Geolocation

    • Property: country, region, or city

    • Condition: equals, contains, etc.

    • E.g., Geolocation.country == "US"

Testing

  • In AEM Author, go to the page with targeting.

  • Enable Targeting mode

  • Open the ContextHub toolbar

  • Modify the Geolocation values manually to simulate location (e.g., change country to India)

  • Check if the correct experience variant is rendered

 

2. URL parameters

 

Setup

  • ContextHub includes a URL store by default
  • You can access values like ContextHub.get('url').parameter.<paramName>
Create a Segment
Create a segment using:
  • Store: URL
  • Property: parameter.campaign
  • Condition: equals summer2024
Testing
Add the parameter to your URL, e.g.:
 
  • ContextHub will automatically parse it

  • Check ContextHub UI → URL Store → Parameters

  • Confirm value is correctly picked up

  • Experience should switch accordingly

 

3. User behaviour

 

ContextHub includes a Profile or Persistence store (via cookies/localStorage)

Create Segments
  • First-Time Users
    • Check if custom flag like visitCount == 1 or hasVisited == false
  • Returning Users
    • Use a flag hasVisited == true or store last visit timestamp
You may need to customize a JavaScript module in ContextHub that tracks this via localStorage or a cookie.
 
(function () {
var visited = localStorage.getItem('hasVisited');
if (!visited) {
localStorage.setItem('hasVisited', 'true');
ContextHub.get('profile').setItem('isFirstVisit', true);
} else {
ContextHub.get('profile').setItem('isFirstVisit', false);
}
})();
 
Testing:
  • Clear your browser localStorage/cookies → simulate first visit

  • Reload → ContextHub Profile store → check isFirstVisit == true

  • Reload again → isFirstVisit == false for returning visitor

 

Verification and debugging Tips:

  • Enable Debug Mode
    • Use ?debug=true in the URL to get additional logs (depending on your config)
  • Use ContextHub Toolbar
    • Visually inspect and manipulate store values
    • Test multiple conditions live without changing the actual URL or location
  • Browser DevTools
    • Check cookies/localStorage for flags
    • Check network tab to validate the page variant/content rendered
  • AEM Logs
    • Use tail -f error.log or request.log to trace segment matching in publish mode

Hope this information helps you.

 

Thanks.

Pradnya

Avatar

Level 2

Thank you Pradnya. This is really helpful. when you say - "In ContextHub, make sure the Geolocation store is enabled (/etc/cloudsettings/default/contexthub)" you mean in CRXDE?