0

サードパーティの開発者と協力して、Paypal と連携して Google アナリティクス サーバー側の e コマース トラッキングを実装します。コード プロジェクト ( http://www.codeproject.com/Articles/493455/Server-side-Google-Analytics-Transactions ) のソース コードを参照して、ステージングで次の Google アナリティクス コードを実装しましたが、トランザクションは発生しません。 :

private void GoogleAnalytics(Order order)
        {
            var wrapper = new HttpRequestWrapper(Request);
 
            try
            {
 
                GoogleRequest request = new GoogleRequest("UA-3820067-1", wrapper);
 
                request.Culture = System.Threading.Thread.CurrentThread.CurrentCulture.ToString();
                request.HostName = System.Web.HttpContext.Current.Request.Url.ToString();
                request.PageTitle = "ShoppingCart";
 
Transaction trans = new Transaction(Convert.ToInt32(order.OrderId), string.IsNullOrEmpty(order.Billing_City) ? (string.IsNullOrEmpty(order.Shipping_City) ? "" : order.Shipping_City) : order.Billing_City, string.IsNullOrEmpty(order.Shipping_Country) ? "" : order.Shipping_Country,
                Convert.ToString(order.RegionId), "store", string.IsNullOrEmpty(order.Shipping_Additional) ? 0 : Convert.ToDecimal(order.Shipping_Additional), Convert.ToDecimal(order.Total), Convert.ToDecimal(order.TaxAmount));
 
                foreach (OrderItem orderItem in order.Items)
                {
                    //ProductCode or SKU, ProductName, ItemPrice, Quantity, GroupName
                    TransactionItem item = new TransactionItem(Convert.ToString(orderItem.SurveyId), orderItem.SurveyName, Convert.ToDecimal(orderItem.Price), orderItem.Quantity, "Survey");
                    trans.AddTransactionItem(item);
                                    }
 
                   //Now just make a request for this transaction object
                    request.SendRequest(trans);
            }
            catch (Exception ex)
            {
                    log.Error("Exception occured while Google Analytics process ", ex);
            }
 
        }

また、取引情報を受信するための Paypal PDT も実装しており、これは現在正常に機能しています。以下は、PDTResponse が成功したときに呼び出しているものです。

if (strResponse.StartsWith("SUCCESS"))
                {
                    PDTHolder pdt = PDTHolder.Parse(strResponse);
                    strCustom = pdt.Custom;
                    strCustom = HttpUtility.UrlDecode(strCustom);
 
 
                    if (strCustom.Contains("&"))
                    {
                        string[] arrCustom = strCustom.Split('&');
                        cc = arrCustom[0].Split('=')[1];
                        pp = arrCustom[1].Split('=')[1];
                        orderID = Convert.ToInt32(arrCustom[2].Split('=')[1]);
                        cartID = arrCustom[3].Split('=')[1];
                    }
 
                    order.OrderId = Convert.ToInt32(orderID);
                    order.LoadByOrderId(Config.SurveyDsn);
                    this.GoogleAnalytics(order);
                }
                else
                {
                    log.Debug("PDT failure");
                }

Paypal から情報を受け取り、Google アナリティクス サーバーに送信するために次に何をすべきか悩んでいるので、これに関する支援をいただければ幸いです。

4

0 に答える 0