Skip to content

Google Analytics (GA)

Google Analytics is maybe the most prominent Webtracking solution for free, but is also available as an enterprise solution, see Analytics 360.

INFO

Google AnalyticsGoogle Analytics (GA) is a web analytics service offered by Google that tracks and reports website traffic, currently as a platform inside the Google Marketing Platform brand.

Google Tag Manager In conjunction with the Google Tag Manager (a tag management system to manage JavaScript and HTML tags, including web beacons, for web tracking and analytics), you can easily add web tracking to an existing application.

Google Search ConsoleGoogle Search Console is a no-charge web service by Google for webmasters. It allows webmasters to check indexing status and optimize visibility of their websites.

Google Analytics 4 (GA4)

Meet the next generation of Google Analytics. Google Analytics 4 (formerly known as "App + Web") is a new kind of property, with several advantages over Universal Analytics:

  • Privacy-focused and durable for the future
  • Intelligent, using machine learning to unearth insights about the customer journey across platforms and devices
  • Enhanced, seamless integrations with Google's advertising platforms to optimize campaign performance and drive greater marketing ROI

Things to know

  • Google Analytics 4 is replacing Universal Analytics
  • On July 1, 2023, standard Universal Analytics properties will no longer process data. You'll be able to see your Universal Analytics reports for a period of time after July 1, 2023. However, new data will only flow into Google Analytics 4 properties.

Adding these events to your website or mobile app helps you measure additional features and behavior as well as generate more useful reports. Because these events require additional context to be meaningful, they're not sent automatically.

For all properties

We recommend these events to all customers in all business verticals. Later sections in this article include some of these events when we recommend sending the events for the given use case.

EventTrigger whenUDINA
ad_impressiona user sees an ad impression, for app only
earn_virtual_currencya user earns virtual currency (coins, gems, tokens, etc.)
join_groupa user joins a group to measure the popularity of each group
logina user logs in
purchasea user completes a purchase
refunda user receives a refund
searcha user searches your content
select_contenta user selects content
sharea user shares content
sign_upa user signs up to measure the popularity of each sign-up method
spend_virtual_currencya user spends virtual currency (coins, gems, tokens, etc.)
tutorial_begina user begins a tutorial
tutorial_completea user completes a tutorial

For online sales

We recommend these events when you want to measure sales on your site or app. They're useful for retail, ecommerce, education, real estate, and travel. Sending the events populates the monetization reports.

EventTrigger whenUDINA
add_payment_infoa user submits their payment information
add_shipping_infoa user submits their shipping information
add_to_carta user adds items to cart
add_to_wishlista user adds items to a wishlist
begin_checkouta user begins checkout
generate_leada user submits a form or a request for information
purchasea user completes a purchase
refunda refund is issued
remove_from_carta user removes items from a cart
select_itema user selects an item from a list
select_promotiona user selects a promotion
view_carta user views their cart
view_itema user views an item
view_item_lista user sees a list of items/offerings
view_promotiona promotion is shown to a user

SAPUI5 Implementation

SAPUI5 works as a Single-Page-Application (SPA) with the need, to sync your router and event flow with the relevant web tracking solution.

INFO

A Single-Page-Application (SPA) is a web application or website that interacts with the user by dynamically rewriting the current web page with new data from the web server, instead of the default method of a web browser loading entire new pages. The goal is faster transitions that make the website feel more like a native app.

To decouple multiple tracking implementations from your application, you can use a component event to loosely track events-on-demand.

Component.js

Register an event handler, to broadcast tracking relevant events from inside you custom controllers.

js
metadata: {
    ...
    events: {
        /**
         * Event is fired on analytics relevant events 
         * to allow tracking in web analytic tools
         */
        analytics: {
            parameters: {
                event: { type: "string" },
                data: { type: "object" }
            }
        }
    }
}

App.controller.js

The main app controller registers relevant events and delegates to helpers.

js
sap.ui.define([
    "sap/ui/core/mvc/Controller",
	"ns/util/GoogleAnalytics",  // Generic Implemention for GA
	"ns/util/SAPWebAnalytics"   // Generic Implemention for SWA
], function (Controller, GoogleAnalytics, SAPWebAnalytics) {
	"use strict";
	return Controller.extend("ns.controller.App", {
        onInit: function () {
            // ...
            // register for component analytics event
            this.getOwnerComponent().attachAnalytics(this._onAnalytics, this);
            // register for route title change event
            // Hint: your router targets inside manifest.json need a localized title!!!
            this.getRouter().attachTitleChanged(this._onTitleChanged, this);
        },

        // handle router title change
        _onTitleChanged: function (oEvent) {
			var sTitle = oEvent.getParameter("title");

			// Example usage: set the browser page title (optional)
			document.title = sTitle;

			var sHash = (location.hash),
				sUrl = "/shop/" + ((sHash.startsWith("#")) ? sHash.substr(2) : "");

			// fire analytics event
			this.getOwnerComponent().fireAnalytics({
				event: "pageView",
				data: {
					page_location: sUrl,
					page_title: sTitle
				}
			});
		},

        // forward analytic events to specific implementation
        _onAnalytics: function (oEvent) {
			var sEvent = oEvent.getParameter("event"),
				mData = oEvent.getParameter("data"),
				sTrackingTool = "GA"; // read default from your app config

			if (sTrackingTool === "GA" && typeof gtag !== "undefined") {
				GoogleAnalytics[sEvent](mData);
			} else if (sTrackingTool == "SWA" && typeof swa !== "undefined") {
				SAPWebAnalytics[sEvent](mData);
			}
		}
	});
});

Custom.controller.js

Loosely trigger web analytics events from your controller.

js
this.getOwnerComponent().fireAnalytics({
    event: "addToCart",
    data: oContext.getObject() // pass in relevant data as object
});