Announcement

Collapse
No announcement yet.

NTFD Page and Google Analytics

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    NTFD Page and Google Analytics

    I was directed to a post on the Miva Blog (thanks Mark and Dan!): Installing Google Analytics In Miva Merchant 5.5. I have implemented it and love the simplicity of the single global footer script and the amount of functionality it provides.

    My question is for the NTFD page. When that page is called, the pageTracker._trackPageview issues a blank product code as part of the url to report. For instance:

    Code:
    <script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>
    <script type="text/javascript">
    var productCode = "";
    var pageTracker = _gat._getTracker("UA-XXXXXX-1");
    pageTracker._trackPageview('/product/' + productCode + '.html');
    </script>
    I modified the script provided in the blog post above (and here) to display 404.html when the NTFD page is called.

    My question is, like the srch parameter trapping, is there a way to pass along the requested url in a parameter and append it to the reported URL?

    So maybe something like this would show up in google analytics as the url that was visited:

    /product/404.html?u=http://www.domain.com/badurl.html

    Thanks!!
    Geoff Manning
    -------------------------
    Miva Sites: Oriental Furniture | Room Dividers

    #2
    Re: NTFD Page and Google Analytics

    The code I tested is this:

    Code:
    ...snip...
    
    <mvt:if expr="g.Screen EQ 'PROD'">
        var productCode = "&mvte:product:code;";
    <mvt:elseif expr="g.Screen EQ 'NTFD'">
        var errorCode = "404";    
    <mvt:elseif expr="g.Screen EQ 'CTGY'">
        var categoryCode = "&mvte:category:code;";
    <mvt:elseif expr="g.Screen EQ 'SRCH'">
        var searchQuery = "&mvte:global:Search;";
    <mvt:else>
        var screenCode = "&mvte:global:screen;";
    </mvt:if>
    
    var pageTracker = _gat._getTracker("UA-XXXXXX-1");
    
    <mvt:if expr="g.Screen EQ 'PROD'">
        pageTracker._trackPageview('/product/' + productCode + '.html');
    <mvt:elseif expr="g.Screen EQ 'NTFD'">
        pageTracker._trackPageview('/error/' + errorCode + '.html');
    <mvt:elseif expr="g.Screen EQ 'CTGY'">
        pageTracker._trackPageview('/category/' + categoryCode + '.html');
    <mvt:elseif expr="g.Screen EQ 'SRCH'">
        pageTracker._trackPageview('/search.html?srch=' + searchQuery);
    
    ...snip...
    It doesn't seem to work, when NTFD is called it is triggering the PROD screen logic above and not the NTFD.
    Geoff Manning
    -------------------------
    Miva Sites: Oriental Furniture | Room Dividers

    Comment


      #3
      Re: NTFD Page and Google Analytics

      You should be able to add it directly to the page conditionals. No real reason to set a Javascript variable if it is always going to be "404":

      Code:
      <mvt:if expr="g.Screen EQ 'PROD'">
      	pageTracker._trackPageview('/product/' + productCode + '.html');
      <mvt:elseif expr="g.Screen EQ 'CTGY'">
      	pageTracker._trackPageview('/category/' + categoryCode + '.html');
      <mvt:elseif expr="g.Screen EQ 'SRCH'">
      	pageTracker._trackPageview('/search.html?srch=' + searchQuery);
      <mvt:elseif expr="(g.screen EQ 'BASK')">
      	pageTracker._trackPageview('/checkout/basket.html');
      <mvt:elseif expr="(g.screen EQ 'NTFD')">
      	pageTracker._trackPageview('/error/404.html');
      <mvt:elseif expr="(g.screen EQ 'ORDL')">
      	pageTracker._trackPageview('/checkout/login.html');
      <mvt:elseif expr="(g.screen EQ 'OCST')">
      	pageTracker._trackPageview('/checkout/address.html');
      <mvt:elseif expr="(g.screen EQ 'OSEL')">
      	pageTracker._trackPageview('/checkout/shipping.html');
      <mvt:elseif expr="(g.screen EQ 'OPAY')">
      	pageTracker._trackPageview('/checkout/payment.html');

      Comment


        #4
        Re: NTFD Page and Google Analytics

        True, good point! I updated my code to reflect that but it still invokes the Screen=PROD code:

        Code:
        <mvt:if expr="g.Screen EQ 'PROD'">
            pageTracker._trackPageview('/product/' + productCode + '.html');
        I'm just not sure why it thinks it's a PROD page.

        The only thing different I am doing in NTFD is sending a 404 header using wcw's Power Search module.

        Code:
        <mvt:item name="powrsrch" param="headeroutput|Status|404 Not Found" />
        Geoff Manning
        -------------------------
        Miva Sites: Oriental Furniture | Room Dividers

        Comment


          #5
          Re: NTFD Page and Google Analytics

          Give this a try... there might be a better way to handle it, but I am just not seeing it yet:

          Code:
          <mvt:if expr="'no longer exists.' IN g.Error_Messages">
                 pageTracker._trackPageview('/error/404.html');

          Comment

          Working...
          X