WordPress.org

Ready to get started?Download WordPress

Forums

PHP WordPress call in Javascript (1 post)

  1. duncan
    Member
    Posted 5 years ago #

    I've been trying to implement a WP php call in Google Analytics code as described on this site
    http://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

Topic Closed

This topic has been closed to new replies.

About this Topic