Skip to main content
Oct 16, 2015 2:28 AM UTC
Solved

How to customize segment using query string or cookie in Adobe CQ5.6?

Hi all,

How to customize segment using query string or cookie in Adobe CQ5.6?

My requirement as follows:

I wanted to target querystring parameters in Segment which is added in my Experience, Teaser, Promotion, Voucher for owned site.

Thanks in advance.

Regards,
Mayur

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
kautuk_sahni
kautuk_sahniAccepted solution
Level 9
Oct 19, 2015 10:55 AM UTC

Hi

Apart from what has Bsloki mentioned, we can create a OSGI which can basically read a query string and can create the content on the run time and then JSP can use that content to render it.

Link:- https://helpx.adobe.com/experience-manager/using/HttpClient_AEM.html (OSGI get request)

Link:- https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html (OSGI Post request)

Link:- http://stackoverflow.com/questions/13592236/parse-the-uri-string-into-name-value-collection-in-java (java code to read query string)

//

public static Map<String, String> splitQuery(URL url) throws UnsupportedEncodingException {Map<String, String> query_pairs = new LinkedHashMap<String, String>();String query = url.getQuery();String[] pairs = query.split("&");for (String pair : pairs) {int idx = pair.indexOf("=");query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));}return query_pairs;}

 

I hope this would help you.

 

Thanks and Regards

Kautuk Sahni

Kautuk Sahni

2 replies

Lokesh_Shivalingaiah
Level 10
Oct 16, 2015 2:28 AM UTC

You can create the custom store/object like query parameters into client context and then use that attributes in your segmentation. refer [1] to see how to create custom client store 

[1] http://blogs.adobe.com/aemtutorials/2013/07/24/customize-the-client-context/

Translate
kautuk_sahni
kautuk_sahniAccepted solution
Level 9
Oct 19, 2015 10:55 AM UTC

Hi

Apart from what has Bsloki mentioned, we can create a OSGI which can basically read a query string and can create the content on the run time and then JSP can use that content to render it.

Link:- https://helpx.adobe.com/experience-manager/using/HttpClient_AEM.html (OSGI get request)

Link:- https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html (OSGI Post request)

Link:- http://stackoverflow.com/questions/13592236/parse-the-uri-string-into-name-value-collection-in-java (java code to read query string)

//

public static Map<String, String> splitQuery(URL url) throws UnsupportedEncodingException {Map<String, String> query_pairs = new LinkedHashMap<String, String>();String query = url.getQuery();String[] pairs = query.split("&");for (String pair : pairs) {int idx = pair.indexOf("=");query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));}return query_pairs;}

 

I hope this would help you.

 

Thanks and Regards

Kautuk Sahni

Translate
Kautuk Sahni