• I’ve been trying to implement a WP php call in Google Analytics code as described on this site
    https://marketingtechblog.com/2009/03/12/how-to-track-by-author-with-google-analytics/

    No matter what I try, WordPress doesn’t see the php is the js itself

    var pageTracker = _gat._getTracker("UA-XXXXXX-X");
    pageTracker._initData();
    <?php if (is_single()) { ?>
    pageTracker._trackPageview(”/author/<?php the_author() ?>”);
    <? } ?>
    pageTracker._trackPageview();

    even stripping out the single call, the author call isn’t seen either

    var pageTracker = _gat._getTracker("UA-XXXXXX-X");
    pageTracker._initData();
    pageTracker._trackPageview(”/author/<?php the_author() ?>”);
    pageTracker._trackPageview();

    The render works, but it doesn’t insert the <?php the_author() ?> like it wasn’t there.

    Any ideas as to why WordPress would be ignoring the php call in the js?

    thx

  • The topic ‘PHP WordPress call in Javascript’ is closed to new replies.