Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

delivering a different response based on region

Avatar

Avatar
Give Back 5
Level 2
prohira
Level 2

Likes

4 likes

Total Posts

56 posts

Correct Reply

3 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 5
Ignite 3
View profile

Avatar
Give Back 5
Level 2
prohira
Level 2

Likes

4 likes

Total Posts

56 posts

Correct Reply

3 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 5
Ignite 3
View profile
prohira
Level 2

15-08-2017

We have a multi-national website. We want to load two JS files let's say test1.js and test2.js on our website based on the user location. The user location is being detected using Akamai EdgeScape headers. Let's say if the user location is China, we want to load test1.js otherwise test2.js should load on the page. The requirement is to load these JS files on server-side, not client-side. These JS files will be included at template level so that they are present in every page on the website.

The problem is: Let's say a user in Country A requests a page /abc.html, the page is served; cached at dispatcher and cached at Akamai edge server (near to user's location) with test2.js present in page source. Now another user requests the same page /abc.html, from China. The page is not available in Akamai edge server (near to user's location i.e. China), so Akamai edge server is going to fetch the page from dispatcher and dispatcher is going to serve the cached page which has test2.js in cache and this defeats the whole purpose.

Points:

1) We can't disable caching pages at dispatcher because it is not one page we are talking about, it's whole site.

2) The file can't be loaded on the client-side because of some purpose.

Thanks in advance!!

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,167 likes

Total Posts

6,285 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,167 likes

Total Posts

6,285 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

18-08-2017

It is recommended to Embed 1 code per website with different rules/logic inside of that.Any sort of wrapper with conditional logic to decide which DTM embed code to use would 1) introduce

Any sort of wrapper with conditional logic to decide which DTM embed code to use would

1) introduce delays in the process

2) technically not supported

~kautuk

Answers (6)

Answers (6)

Avatar

Avatar
Validate 1
Level 1
nasrinj31078225
Level 1

Like

1 like

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Give Back
Boost 1
View profile

Avatar
Validate 1
Level 1
nasrinj31078225
Level 1

Like

1 like

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Give Back
Boost 1
View profile
nasrinj31078225
Level 1

10-06-2021

Hi @prohira ,

 

How you fetched Akamai EdgeScape headers in AEM/Java code.

We tried by simply fetching headers, but it's not working.

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,167 likes

Total Posts

6,285 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,167 likes

Total Posts

6,285 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

16-08-2017

I am not sure about OOTB, but you can certainly upload JS conditionally.

Example :- html - Conditionally load JavaScript file - Stack Overflow

But, why not to upload 1 JS file and keep logic in it?

~kautuk

Avatar

Avatar
Give Back 5
Level 2
prohira
Level 2

Likes

4 likes

Total Posts

56 posts

Correct Reply

3 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 5
Ignite 3
View profile

Avatar
Give Back 5
Level 2
prohira
Level 2

Likes

4 likes

Total Posts

56 posts

Correct Reply

3 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 5
Ignite 3
View profile
prohira
Level 2

16-08-2017

Hello Kautuk,

I forgot to mention, we are using AEM 6.1, so Experience Fragment doesn't fit here.

The issue is how to load appropriate DTM JS file in the head section. You are right, "via DTM we can certainly load any number of scripts" but here I am looking to load different DTM JS files based upon user location.

Thanks.

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,167 likes

Total Posts

6,285 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,167 likes

Total Posts

6,285 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

15-08-2017

You can achieve this personalization by:

1. AEM Context Hub Working with Experience Fragments and the Experience Manager ContextHub

// The implementation usage is not same as DTM, it is not used for uploading JS on the page. For uploading JSs use DTM.

2. AEM Target engine (similar to Context Hub)

3. Using Adobe Target with AEM via DTM Adobe Experience Manager Help | Integrating Adobe Experience Manager with Adobe Analytics and Target...

// Via DTM you can certainly load any number of scripts.

~kautuk

Avatar

Avatar
Give Back 5
Level 2
prohira
Level 2

Likes

4 likes

Total Posts

56 posts

Correct Reply

3 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 5
Ignite 3
View profile

Avatar
Give Back 5
Level 2
prohira
Level 2

Likes

4 likes

Total Posts

56 posts

Correct Reply

3 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 5
Ignite 3
View profile
prohira
Level 2

15-08-2017

Hi Scott,

I need to load the JS (test1.js or test2.js) in head section. Would it be possible thru Context Hub/Personalization? FYI: these JS files are DTM JS, if that makes any difference.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

15-08-2017

You are referring to AEM personalization. To work with Geo Data - you can use ContextHub and segments. See this article:

Scott's Digital Community: Using the ContextHub with the Experience Manager Toy Store site

You can load different components/clientlibs (which load JS files) for a page based on Geo data.

Also - you can load different Experience Fragments too based on the audience - which can be different locations:

Working with Experience Fragments and the Experience Manager ContextHub