Analytics Tip
Analytics does a good job tracking hits and visits to any of the portal’s knowledge directory cards (documents and URLs.) But, often enough, we don’t view the KD cards by navigating the directory and browsing its content since we might want to reference certain cards through Publisher content items or through custom apps using <HREF> tags. If tracking hits for such cards isn’t essential, then it is safe to just plug the gatewayed URL to that document as in:
<A HREF=" http://<PortalServerHost>/portal/server.pt/gateway/PTARGS_0_19159_12345_0_0_18/MyDocument.docx ">Click Here</A>
That link, when referenced in a custom app or a Publisher content item, will not trigger a hit in Analytics.
However, should we need to track those cards’ hits then we have to alter the URL and use the native JavaScript API libraries and specifically the PTCommonOpener class. That class is resident in every page in the portal therefore it can be called from any portlet. The JS function in the PTCommonOpener class that opens a card and triggers the Analytics’ hit increment is getOpenerURLOpenObjID. The method takes few parameters but is best illustrated with an example:
<A HREF=" OnClick="PTCommonOpener.openInSameWindow(PTCommonOpener.getOpenerURLOpenObjID(18, 12345, '', 2)); return false;"">Click Here</A>
The arguments for getOpenerURLOpenObjID are:
- 18: The numeric ID for the type of object. For the most part it will be 18 for knowledge directory cards.
- 12345: The object id for the card that you need to open and track its hits count.
- The third parameter is optional but can be used to pass additional arguments to the query string.
- 2: Denotes that we are opening the item in view mode.
It is worth noting that the gatewayed URL also includes some of the getOpenerURLOpenObjID arguments: e.g. the object id for the card we want to view in the third argument (in this example it is 12345) as well as the class id in the 6th argument (18).
Thanks.
Hani
- Log in to post comments