I am building a custom report on top of Piwik’s reporting API. On page load, each page fires a set of events (via trackEvent) and sets a custom dimension (via setCustomDimension). I use this to store some additional metadata about the page that is shown.
Now the target scenario I want to achieve: If the user clicks on a link on such a page, I want to relate this link click to the events and custom dimension of the page.
For instance, one of the pages is a search result page, and I am sending the search terms as a custom event. If the user clicks on a link, I want to know which search term the link referred to. In my custom report, I want to query: "Give me all links a user clicked on after search for ". Likewise, I would like to query: "Give me all links a user clicked on page of type " (where the page type is stored in a custom dimension).
Is it possible somehow to retrieve additional info about a link click to find out in which context it occured (i.e. by relating it to the events and custom dimension the page itself set)? Alternatively, is it possible to tell Piwik to fire events / set custom dimensions along with the link click itself?
I am also interested in any docs about how “link tracking” works in general. If I activate it on a page, I only see Piwik tracking the analytics data of the target page, but I don’t see additional tracking of the link click itself.