• Hi,

    Still a great fan of this plugin. After having it in use for some while, I now was interested in seeing how often this navigation is actually clicked by visitors and to see what sections they jump to.

    This is not a feature request, the code to do it is below for anybody interested. But maybe you want to include an option to toggle this in future versions? I don’t know – might be of use to some, hence I posted it here.

    Requries a Google (Universal) Analytics account running on the page.

    The only change is in toc.php, in line 1340 (i.e just above if ( $this->options['ordered_list'] ) {

    There you simply enter the following two lines, replacing line 1340: ` $intlink=$this->url_anchor_target( $matches[$i][0] );
    $html .= ‘<a href=”#’ . $intlink . ‘” onClick=”ga(\’send\’, \’event\’, \’TOCPlus\’, \’Click\’, \”. $_SERVER[‘REQUEST_URI’].’#’.$intlink.’\’);”>’;`

    (If you do not create the $intlink (internal link) variable, an ugly-looking 2 will be appended in the link or the event.)

    This small change fires a code that will turn up in google (universal) analytics in events as as Category:TOCPlus > Action: Click > Label:URL#Anchor without domain name.

    Hope somebody might find this useful.

    Regards,
    NZ

    https://www.ads-software.com/plugins/table-of-contents-plus/

  • The topic ‘Tracking TOC-Clicks’ is closed to new replies.