Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Getting Tag title from javascript


Level 3

Hi all,

From one javascript file I am receiving the following array:

tags ["parenttag:tag1/subtag1", "parenttag:tag1/subtag2", "parenttag:tag1/subtag3", "parenttag:tag2/subtag4", "parenttag:tag2/subtag5"]

I would need to get each tag title from these values. E.g from "parenttag:tag1/subtag1" the tag title is defined as "Subtag 1"

Is there any way of doing this from javascript?


Thank you.

8 Replies




Let say:

Var a = ["parenttag:tag1/subtag1", "parenttag:tag1/subtag2", "parenttag:tag1/subtag3", "parenttag:tag2/subtag4", "parenttag:tag2/subtag5"];

So ,

a[0] would print :-  "parenttag:tag1/subtag1"

a.length := 5


Var result = a[0].split("/");

result would be  :- ["parenttag:tag1", "subtag1"]

and  result[1] would give you:-  "subtag1"


Now repeat this in a for loop from 1 to a.length

I hope this would help you.

Thanks and Regards

Kautuk Sahni

Kautuk Sahni


Level 3

Hi kautuksahni,

thanks for you help but I am afraid that does not work for me, as I could have "parenttag:tag1/subtag1" which its actual title could be "Little Kitties"

Is any CQ object I can call from the front end to get this value? or any other way/workaround to do so?


Level 10

AFAIK, there is no OOTB direct way to resolve the tag and get the title in JS

But you might want to look into the code of tagpicker field in TOUCH UI and one option can be a servlet where you can pass Id's in one go and get all title



Level 10

Trying to read the DOM to get tags information is not best practice. 

There are much better ways to get Tag in AEM via the Tag Manager API. See these articles: 

Developing a Sightly Component that searches for AEM Content Tags

Using Custom Tag Libraries to search for AEM Content Tag

Hope these help


Level 2

you can do like this, it's very simple,


          type: "GET",

          url: "/etc/tags/TestTag/"+Tagid+".json", //

          success : function(data) {

               TagTitle= data["jcr:title"];




Level 10

No, I don't think it's simple.

1. Direct URL could be blocked via dispatcher.

2. By default, Anonymous user does not have tags permission. https://docs.adobe.com/docs/en/aem/6-2/administer/content/tags.html#Setting Tag Permissions