Instrument a theme for Active Site Analytics
WebSphere Portal provides the Page Builder theme that is prepared and suitable for use with Active Site Analytics. You can also enhance the other portal themes or create own custom theme to utilize the Active Site Analytics functionality.
In order make Active Site Analytics work in a custom theme, you need to do the following:
For more details about these tasks refer to the following sections:
- Add metadata to the page.
- Include an aggregator with the page.
- Include microformats of interest, that is related to the statistical data that you want to collect.
Add metadata to the pageAn aggregator picks up information stored in the DOM (document object model) tree of a page. This information must be present in the HTML source of the page. The recommended approach to add this information to a page is to implement the theme or skin so that they write all the necessary information into the DOM tree of the page. Examples:
- You can add the identifier of a portlet to the DOM tree by adding the following line to the file skin.html in the theme WebDAV folder:
<span class="asa.portlet.id" style="display:none;"><%= myPortletID %></span>If the span element is styled in an external CSS file, you need to escape each period in the class name by a backslash. Example: asa/.portlet/.id{display:none;}By the code sample above the aggregator can fetch the identifiers of all portlets on a page by iterating over all occurrences of "span" elements with a class attribute of "asa.portlet.id".
The correct function of the code sample above depends on the definition of myPortletID earlier in the file skin.html. By default, it is defined by using the following JSP code:
<portal-skin:portletID var="myPortletID"/> <jsp:useBean id="myPortletID" class="java.lang.String" scope="page"/>
You can add the portlet title to the DOM tree by wrapping the <portal-skin:portletTitle> statement in the file skin.html with a span element that has a class attribute of "asa.portlet.title": <span class="asa.portlet.title"><portal-skin:portletTitle></portal-skin:portletTitle</span>
Including aggregators with the pageThe portal ships a default implementation of the theme extension point com.ibm.portal.theme.plugin.ActiveSiteAnalyticsItems. It locates and includes a JavaScript with a name that corresponds to the value specified by the key asa_aggregator given with the page metadata. Add the following code somewhere near the closing body tag ( </body> ) of the themeName/nls/theme_languageCode.html file of the theme WebDAV folder:
<portal-theme-ext:themeExtension id="com.ibm.portal.theme.plugin.ActiveSiteAnalyticsItems"> <portal-theme-ext:themeExtensionLoop> <portal-theme-ext:themeExtensionItemText /> </portal-theme-ext:themeExtensionLoop> </portal-theme-ext:themeExtension>This code loops over every implementation of the theme extension point and executes it. The default implementation shipped with the portal follows the approach outlined above.
Including microformats of interestYou might need to modify the skins used by a theme so that all of the microformat information that you want to be captured is present when the page is rendered. For example, you can add this code to the skin.html file of a skin to ensure the portlet ID of all portlets on the page is available for the aggregator script to discover:
<span class="asa.portlet.id" style="display:none;"><%= myPortletID %></span>In this case the file asa_sample.js looks for elements with the class asa.portlet.id to find the portlet ID of all portlets present on the page. Portlet titles can be rendered by using code similar to this:
<portal-skin:portletTitle />To capture such portlet titles, you can add an additional span element with a class defined for titles that the analytics JavaScript file will look for:
<span class="asa.portlet.title"><portal-skin:portletTitle /></span>In this case, asa.portlet.title is recognized as the class for all span elements that encompass the rendered text of the portlet titles.
Parent
Analyzing user behavior by Active Site Analytics
How Active Site Analytics data is represented in the portal
Related tasks
Writing an aggregator for Active Site Analytics
Add an Active Site Analytics aggregator to a portal page
Configure an aggregator at runtime
Inject custom aggregators
Aggregator JSP