Google Adwords conversion tracking Not working.

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
jhmac
Ensign (ENS)
Ensign (ENS)
Posts: 13
Joined: Thu Dec 02, 2010 10:02 am

Google Adwords conversion tracking Not working.

Post by jhmac » Wed Dec 05, 2012 1:12 pm

I can not get my google analytics to show the Order.TotalCharges . I can see the analytics but no order totals. I am want to determine ROI for advertising.

I have looked at these threads but they did not work for me.
http://help.ablecommerce.com/mergedProj ... lytics.htm,
viewtopic.php?f=42&t=11325

Any help would be appreicaited.

I am using the following code with my id's, not the xxxxxxxx.

Code: Select all

    <!-- Google Code for Purchase/Sale Conversion Page -->
    <script language="JavaScript" type="text/javascript">
    <!--
    var google_conversion_id = xxxxxxxxxxxx;
    var google_conversion_language = "en_US";
    var google_conversion_format = "3";
    var google_conversion_color = "ffffff";
    var google_conversion_label = "xxxxxxxxxxxxxxxxx";
    if (<%= Order.TotalCharges%>) {
      var google_conversion_value = <%= Order.TotalCharges%>;
    }
    //-->
    </script>
    <script language="JavaScript" src="https://www.googleadservices.com/pagead/conversion.js">
    </script>
    <noscript>
    <img height="1" width="1" border="0" src="https://www.googleadservices.com/pagead/conversion/xxxxxxxxxx/?value=<%= Order.TotalCharges%>&label=xxxxxxxxxxxxxxxxx&guid=ON&script=0"/>
    </noscript>


User avatar
david-ebt
Captain (CAPT)
Captain (CAPT)
Posts: 253
Joined: Fri Dec 31, 2010 10:12 am

Re: Google Adwords conversion tracking Not working.

Post by david-ebt » Wed Dec 05, 2012 2:50 pm

This is what we're using for the GoogleCheckoutWidget control:

GoogleCheckoutWidget.ascx

Code: Select all

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="GoogleCheckoutWidget.ascx.cs" Inherits="ConLib_GoogleAnalyticsWidget" EnableViewState="false" %>
<%--
<conlib>
<summary>Widget for Google Analytics Tracking.</summary>
</conlib>
--%>
<%@ Register Assembly="CommerceBuilder.Web" Namespace="CommerceBuilder.Web.UI.WebControls" TagPrefix="cb" %>
<asp:PlaceHolder ID="trackingPanel" runat="server">
<!-- Google Code for Purchase/Sale Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = <%=this.GoogleAdwordsId%>;
var google_conversion_language = "en";
var google_conversion_format = "2";
var google_conversion_color = "ffffff";
var google_conversion_label = "xxxxxxx";
var google_conversion_value = 0;
if (<%=this.OrderTotal %>) {
  google_conversion_value = <%=this.OrderTotal %>;
}
/* ]]> */
</script>
<script type="text/javascript" src="https://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="https://www.googleadservices.com/pagead/conversion/xxxxxxx/?value=<%=this.OrderTotal %>&label=xxxxxx&guid=ON&script=0"/>
</div>
</noscript>
</asp:PlaceHolder>
GoogleCheckoutWidget.ascx.cs

Code: Select all

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CommerceBuilder.Common;
using CommerceBuilder.Catalog;
using CommerceBuilder.Orders;
using CommerceBuilder.Stores;
using CommerceBuilder.Utility;
using CommerceBuilder.Products;

public partial class ConLib_GoogleAnalyticsWidget : System.Web.UI.UserControl
{
    private StoreSettingCollection _Settings;
    private Order _Order;
    private int _OrderId = 0;

    protected string GoogleAdwordsId
    {
        get
        {
            return "xxxxxxx";
        }
    }

    private bool IsReceiptPage
    {
        get
        {
            return (Request.FilePath.IndexOf("Checkout/Receipt.aspx", StringComparison.InvariantCultureIgnoreCase) >= 0);
        }
    }

    protected string OrderTotal
    {
        get
        {
            LSDecimal shipping = 0;
            LSDecimal taxes = 0;
            LSDecimal total = 0;
            foreach (OrderItem item in _Order.Items)
            {
                LSDecimal extendedPrice = item.ExtendedPrice;
                switch (item.OrderItemType)
                {
                    case OrderItemType.Shipping:
                    case OrderItemType.Handling:
                        shipping += extendedPrice;
                        break;
                    case OrderItemType.Tax:
                        taxes += extendedPrice;
                        break;
                    default:
                        break;
                }
                total += item.ExtendedPrice;
            }

            return total.ToString("N");
        }
    }

    protected void Page_Init(object sender, EventArgs e)
    {
        trackingPanel.Visible = false;
        if (this.IsReceiptPage)
        {
            _OrderId = AlwaysConvert.ToInt(Request.QueryString["OrderId"]);
            _Order = OrderDataSource.Load(_OrderId);
            if (_Order != null && _Order.Items.Count > 0)
            {
                trackingPanel.Visible = true;
            }
        }
    }
}
David
http://www.ecombuildertoday.com
Enhanced Reporting for AbleCommerce
Image

jhmac
Ensign (ENS)
Ensign (ENS)
Posts: 13
Joined: Thu Dec 02, 2010 10:02 am

Re: Google Adwords conversion tracking Not working.

Post by jhmac » Tue Jan 29, 2013 11:33 am

Sorry I am just now getting back to you David.
Thanks for the help, but it did not work. We have had crazy problems with able. Many things are not working on our site for some reason. Things like people being able to order(kind of important). We are doing an install of GOLD from scratch and hopefully this will fix our problems. We have our fingers crossed. Thanks again for you help.

jhmac
Ensign (ENS)
Ensign (ENS)
Posts: 13
Joined: Thu Dec 02, 2010 10:02 am

Re: Google Adwords conversion tracking Not working.

Post by jhmac » Fri Feb 08, 2013 11:39 am

David,
I am working on your option and have a question.
the code:

Code: Select all

 get
        {
            return "xxxxxxx";
        }
Do I replace the "xxxxxxxx" with my adwords customer ID?


Also, Do I add it to the page like the GoogleAnalyticsWidget?

Code: Select all

<%@ Register src="~/ConLib/GoogleAnalyticsWidget.ascx" tagname="GoogleAnalyticsWidget" tagprefix="uc" %>
<%@ Register src="~/ConLib/GoogleCheckoutWidget.ascx" tagname="GoogleCheckoutWidget" tagprefix="uc" %>

 <uc:GoogleAnalyticsWidget ID="GoogleAnalyticsWidget1" runat="server" />
 <uc:GoogleCheckoutWidget ID="GoogleCheckoutWidget1" runat="server" />
thanks

Post Reply