Expand my Community achievements bar.

SOLVED

Count number of times component has been used

Avatar

Level 2

Hey , is there a way that i can find the number of times a component as been used in the website? i want a number count of the most used components in the website . any easy way to do this?

Topics

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Zendarkke ,

OOTB you can check the components page (eg:- http://localhost:4502/libs/wcm/core/content/sites/components.html)  . Upon clicking on the required component it can show the list of pages where the component is used. That can give you an idea of the usage of the component. Groovy script or SQL query can be another way to get the exact count.

 

Thanks,

Somen

View solution in original post

4 Replies

Avatar

Community Advisor

Hi There are couple of ways you can approach using querybuilder or using groovy scripts to find the list of components and occurrences. 

 

If you want to do it using the query tool you will have to start with basic sql2 query as aggregations wont be supported and deduplicate and build your results .

 

SELECT [sling:resourceType] FROM [nt:unstructured]
WHERE ISDESCENDANTNODE([/content/www/XX/XX/test])
AND [sling:resourceType] IS NOT NULL

 

Also keep in mind the performance aspect and adjust the search nodes appropriately

Avatar

Correct answer by
Community Advisor

Hi @Zendarkke ,

OOTB you can check the components page (eg:- http://localhost:4502/libs/wcm/core/content/sites/components.html)  . Upon clicking on the required component it can show the list of pages where the component is used. That can give you an idea of the usage of the component. Groovy script or SQL query can be another way to get the exact count.

 

Thanks,

Somen

Avatar

Community Advisor

Just adding what @somen-sarkar and @sherinregi already suggested, if you are using ACS Common then use Component Report Builder



Arun Patidar

Avatar

Community Advisor

Hi @Zendarkke ,

Try query to get the count from pages.

Example :

SELECT COUNT(*)
FROM [nt:base] AS root
WHERE ISDEEP TRUE AND root.[jcr:primaryType] = 'nt:unstructured'
AND root.[jcr:content/@sling:resourceType] LIKE '/apps/%'

 

Thanks

Himanshu Jain