How to add custom tracking JavaScript code at the bottom of each aMember's page

From aMember Pro Documentation
Revision as of 02:44, 19 November 2013 by Alexander (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Create file /amember/application/configs/site.php with this code:

<?php
 
// Setup hook that will be executed before page render
Am_Di::getInstance()->hook->add(Am_Event::BEFORE_RENDER, 'addTrackingCode');
 
function addTrackingCode(Am_Event $e){
 
    // Do not add tracking code to Admin pages. 
    if(defined('AM_ADMIN')) return;
 
 
    $view = $e->getView();
 
    // Output your code before closing </body> tag
    $view->placeholder('body-finish')->append(<<<EOT
<script>
 
PUT YOUR TRACKING JAVASCRIPT CODE HERE
 
</script>
EOT
        );
}