WordPress Login Tracking Google Analytics

There might be a way to do this in your plugin (depends on the plugin), but assuming the Analytics code is added in the header, you could add the following just before </head> in header.php:

<?php if (is_user_logged_in()) { ?>
    <script type="text/javascript">
        _gaq.push(['_setCustomVar',
            1,             
            'User Type', 
            'Member',      
            2
        ]);
    </script>
<?php } ?>

It’s untested, but it should do the trick.

Leave a Comment