How to customize segment using query string or cookie in Adobe CQ5.6? | Community
Skip to main content
October 16, 2015
Solved

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

  • October 16, 2015
  • 2 replies
  • 1071 views

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.
Best answer by kautuk_sahni

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

2 replies

Lokesh_Shivalingaiah
October 16, 2015

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/

kautuk_sahni
Community Manager
kautuk_sahniCommunity ManagerAccepted solution
Community Manager
October 19, 2015

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