Yesterday, between presentations, a lady asked my advice on how to solve a problem with APEX. I think I pointed her in the right direction, but I think the solution is a little more complex than I'd indicated (though not too much more). So this is just a quick post on how to do this, in the hopes that it'll help anyone trying to do the same thing.
Basically, her requirements were that she had a report; one of the columns was a link, and she needed to track whenever a user clicked on one of the links (and where it went to). My solution was to use a dynamic action, using the a[…] jQuery selector to attach it to the appropriate URLs, and have the action be a PL/SQL block. Simple, straightforward…and not quite good enough.
The problem, of course, is that the PL/SQL block doesn't have any way to tell which link was clicked on. We can tell that a link was clicked, but that's not enough.
After giving it some thought, I think the easiest solution would be to create a hidden page item–P1_CLICKEDLINK, or some such–and then change the dynamic action to a two-step process. The first step should be an “Execute JavaScript Code”, which sets the hidden page item to this.triggeringElement.href; the second step would be to Execute PL/SQL code, submitting the hidden page item, and using that value to store in the log table.
Please note–I haven't had time to test this solution out yet. Hopefully, I'll have some time to throw together a demo of this solution, but this is a fairly busy week, so no promises…
Leave a Reply