0 Replies Latest reply on Sep 2, 2008 4:31 PM by Newsgroup_User

    Coldfusion and Google ecommerce tracking

    Level 7
      Just trying to implement google ecommerce tracking on my coldfusion based
      shopping cart thankyou for your order page.

      Ive never output a coldfusion query to javascript just want to make sure i
      have the syntax correct. would the way ive output the coldfusion query
      reults into the javascript below be ok?

      Thanks in advance !




      <!-------------queries to get last order---------->
      <cfquery name="order" datasource="#client.dsn#" username="#client.username#"
      password="#client.password#">
      SELECT max(I_orderid) as I_orderid
      FROM oheader </cfquery>

      <cfquery name="order2" datasource="#client.dsn#"
      username="#client.username#" password="#client.password#">
      SELECT * from oheader where I_orderid=#order.i_orderid#
      </cfquery>

      <cfquery name="lines" datasource="#client.dsn#" username="#client.username#"
      password="#client.password#">
      SELECT * from olines where I_orderid=#order.i_orderid#
      </cfquery>

      <!----google e-com tracking--------->
      <script type="text/javascript">
      var pageTracker = _gat._getTracker("UA-399397-1");
      pageTracker._trackPageview();

      <!------Output query results into javascript-------->
      <cfoutput query="order2">

      pageTracker._addTrans(

      "#i_orderid#", // Order ID

      "#d_grandtotal#" // Total

      );
      </cfoutput>

      // add item might be called for every item in the shopping cart
      // where your ecommerce engine loops through each item in the cart and
      // prints out _addItem for each

      <cfoutput query="lines" >
      pageTracker._addItem(
      "#lines.i_orderid#", // order ID
      "#lines.s_partno#", // SKU/code - required
      "#lines.d_price#", // unit price - required
      "#lines.i_quantity#" // quantity - required
      );
      </cfoutput>
      pageTracker._trackTrans();
      </script>