Пример #1
0
        private void SetupAnalytics()
        {
            if (siteSettings.GoogleAnalyticsAccountCode.Length == 0)
            {
                return;
            }
            if (thread == null)
            {
                return;
            }
            if (thread.Subject.Length == 0)
            {
                return;
            }

            AnalyticsAsyncTopScript asyncAnalytics = Page.Master.FindControl("analyticsTop") as AnalyticsAsyncTopScript;

            if (asyncAnalytics != null)
            {
                string urlToTrack = ForumConfiguration.FakeTrackingBaseUrl + SiteUtils.SuggestFriendlyUrl(thread.Subject, siteSettings);
                asyncAnalytics.PageToTrack = urlToTrack;
            }
        }
        private void DoAsyncTracking()
        {
            AnalyticsAsyncTopScript analytics = Page.Master.FindControl("analyticsTop") as AnalyticsAsyncTopScript;

            if (analytics == null)
            {
                return;
            }

            AnalyticsTransaction transaction = new AnalyticsTransaction();

            transaction.OrderId   = order.OrderGuid.ToString();
            transaction.City      = order.CustomerCity;
            transaction.Country   = order.CustomerCountry;
            transaction.State     = order.CustomerState;
            transaction.StoreName = siteSettings.SiteName + " - " + store.Name;
            transaction.Tax       = order.TaxTotal.ToString(CultureInfo.InvariantCulture);
            transaction.Total     = order.OrderTotal.ToString(CultureInfo.InvariantCulture);

            foreach (OrderOffer offer in order.OrderOffers)
            {
                AnalyticsTransactionItem item = new AnalyticsTransactionItem();
                item.Category    = string.Empty;
                item.OrderId     = order.OrderGuid.ToString();
                item.Price       = offer.OfferPrice.ToString(CultureInfo.InvariantCulture);
                item.ProductName = offer.Name;
                item.Quantity    = offer.Quantity.ToInvariantString();
                item.Sku         = offer.OfferGuid.ToString();
                transaction.Items.Add(item);
            }

            if (transaction.IsValid())
            {
                analytics.Transactions.Add(transaction);
                Order.TrackAnalytics(order.OrderGuid);
            }
        }