private void TrackAfterPayment(ReceiptViewModel model) { // Track Analytics GoogleAnalyticsTracking tracking = new GoogleAnalyticsTracking(ControllerContext.HttpContext); // Add the products int i = 1; foreach (OrderLineViewModel orderLine in model.Order.OrderLines) { if (string.IsNullOrEmpty(orderLine.Code) == false) { tracking.ProductAdd(code: orderLine.Code, name: orderLine.Name, quantity: orderLine.Quantity, price: (double)orderLine.Price, position: i ); i++; } } // And the transaction itself tracking.Purchase(model.Order.OrderNumber, null, (double)model.Order.TotalAmount, (double)model.Order.Tax, (double)model.Order.Shipping); }
public override ActionResult Index(RecommendedProductsBlock currentBlock) { List <ProductListViewModel> models = new List <ProductListViewModel>(); RecommendedResult recommendedResult = new RecommendedResult(); var currentCustomer = CustomerContext.Current.CurrentContact; var recommendedProducts = GetRecommendedProducts(currentBlock); foreach (var content in recommendedProducts.Products) { ProductListViewModel model = null; VariationContent variation = content as VariationContent; if (variation != null) { model = new ProductListViewModel(variation, _currentMarket.GetCurrentMarket(), currentCustomer); } else { ProductContent product = content as ProductContent; if (product != null) { model = _productService.GetProductListViewModel(product as IProductListViewModelInitializer); if (model == null) { model = new ProductListViewModel(product, _currentMarket.GetCurrentMarket(), currentCustomer); } } } if (model != null) { model.TrackingName = recommendedProducts.RecommenderName; models.Add(model); // Track ControllerContext.HttpContext.AddRecommendationExposure(new TrackedRecommendation() { ProductCode = model.Code, RecommenderName = recommendedProducts.RecommenderName }); GoogleAnalyticsTracking tracker = new GoogleAnalyticsTracking(ControllerContext.HttpContext); tracker.ProductImpression( model.Code, model.DisplayName, null, model.BrandName, null, currentBlock.Heading); } } recommendedResult.TrackingName = recommendedProducts.RecommenderName; recommendedResult.Heading = currentBlock.Heading; recommendedResult.Products = models; return(View("_recommendedProductsBlock", recommendedResult)); }
private void TrackBeforePayment(IEnumerable <LineItem> lineItems) { // Track Analytics. GoogleAnalyticsTracking tracking = new GoogleAnalyticsTracking(ControllerContext.HttpContext); // Add the products int i = 1; foreach (LineItem lineItem in lineItems) { tracking.ProductAdd(code: lineItem.Code, name: lineItem.Name, quantity: (int)lineItem.Quantity, price: (double)lineItem.PlacedPrice, position: i ); i++; } // Step 3 is to pay tracking.Action("checkout", "{\"step\":3}"); // Send it off tracking.Custom("ga('send', 'pageview');"); }
private void TrackProductImpressions(ProductSearchResult productSearchResult) { foreach (var product in productSearchResult.Products) { GoogleAnalyticsTracking tracker = new GoogleAnalyticsTracking(ControllerContext.HttpContext); tracker.ProductImpression( product.Code, product.DisplayName, null, product.BrandName, null, "Product Search Block"); } }
private void Track(List <Core.Objects.LineItem> lineItems) { // Track Analytics. GoogleAnalyticsTracking tracking = new GoogleAnalyticsTracking(ControllerContext.HttpContext); // Add the products int i = 1; foreach (Core.Objects.LineItem lineItem in lineItems) { tracking.ProductAdd(code: lineItem.Code, name: lineItem.Name, quantity: (int)lineItem.Quantity, price: (double)lineItem.PlacedPrice, position: i ); i++; } // Step 2 is the checkout page tracking.Action("checkout", "{\"step\":2}"); }
protected void TrackAnalytics(DigitalCameraVariationViewModel viewModel) { // Track GoogleAnalyticsTracking tracking = new GoogleAnalyticsTracking(ControllerContext.HttpContext); tracking.ClearInteractions(); // Track the main product view tracking.ProductAdd( viewModel.CatalogVariationContent.Code, viewModel.CatalogVariationContent.DisplayName, null, viewModel.CatalogVariationContent.Facet_Brand, null, null, 0, (double)viewModel.CatalogVariationContent.GetDefaultPriceAmount(_currentMarket.GetCurrentMarket()), 0 ); // TODO: Track related products as impressions // Track action as details view tracking.Action("detail"); }
private void Track(CartModel model) { // Track Analytics. // TODO: Remove when GA add-in is fixed GoogleAnalyticsTracking tracking = new GoogleAnalyticsTracking(ControllerContext.HttpContext); // Add the products int i = 1; foreach (LineItem lineItem in model.LineItems) { tracking.ProductAdd(code: lineItem.Code, name: lineItem.DisplayName, quantity: (int)lineItem.Quantity, price: (double)lineItem.PlacedPrice, position: i ); i++; } // Step 1 is to review the cart tracking.Action("checkout", "{\"step\":1}"); }
protected void TrackAnalytics(IVariationViewModel <GenericSizeVariationContent> viewModel) { // Track GoogleAnalyticsTracking tracking = new GoogleAnalyticsTracking(ControllerContext.HttpContext); tracking.ClearInteractions(); // Track the main product view tracking.ProductAdd( viewModel.CatalogContent.Code, viewModel.CatalogContent.DisplayName, null, null, null, null, 0, viewModel.CatalogContent.GetDefaultPriceAmountWholeNumber(_currentMarket.GetCurrentMarket())); // TODO: Track related products as impressions // Track action as details view tracking.Action("detail"); }
public string GetPromotionClickScript(string id, string name, string bannerName) { var tracking = new GoogleAnalyticsTracking(_contextProvider.GetContext()); return(tracking.PromotionClickScript(id, name, bannerName)); }
public void TrackPromotionImpression(string id, string name, string bannerName) { var tracking = new GoogleAnalyticsTracking(_contextProvider.GetContext()); tracking.PromotionImpression(id, name, bannerName); }