Enhancing privacy-focused Web Analytics to better meet your metrics needs

Enhancing privacy-focused Web Analytics to better meet your metrics needs

Enhancing privacy-focused Web Analytics to better meet your metrics needs

Last December we opened up our brand new privacy-first Web Analytics platform to everyone. Today, we’re excited to announce the release of three of the most requested features: adding multiple websites to an account, supporting Single-page Applications (SPA) as well as showing Core Web Vitals in Web Analytics.

Bringing privacy-first analytics to everyone

Since we launched two months ago, we’ve received a lot of feedback from our users. We are really happy that we are able to provide our privacy-first analytics to so many of you.

Popular analytics vendors have business models driven by ad revenue. Using them implies a bargain: they track visitor behavior and create buyer profiles to retarget your visitors with ads; in exchange, you get free analytics.

Our mission is to help build a better Internet, and part of that is to deliver essential web analytics to everyone with a website without compromising user privacy. We’ve never been interested in tracking users or selling advertising. We don’t want to know what you do on the Internet — it’s not our business.

You now can measure multiple sites

When we launched Web Analytics, each account was only able to measure one website. We are happy to announce that all users can now add up to 10 websites.

Add one or more new sites via the Cloudflare Dashboard by selecting “Add site” in Quick Actions.

Enhancing privacy-focused Web Analytics to better meet your metrics needs

For measuring multiple subdomains (a.example.com and b.example.com) there are two options:

  • Add the root domain (example.com) to Web Analytics and add the same JavaScript snippet on all subdomains (a.example.com and b.example.com)
  • Add the subdomains separately using multiple sites. Here you have to add separate snippets.
  • We use the hostname to validate the request, so remember that you can only use the JavaScript snippet if both the configured and actual hostnames match.

    You can see the analytics for all your websites sites in one place

    Enhancing privacy-focused Web Analytics to better meet your metrics needs

    When we talked to customers about the multiple site feature, we got the feedback that it is very important to add all sites to Web Analytics and be able to track them. But they also said that it would be even more powerful to have the option to see analytics for all your sites combined in one place.

    We listened. If you select “View Web Analytics for all sites’ on the Web Analytics overview page, you can now see all your sites listed and apply filters to them using site tags.

    What is different for Single Page Applications (SPA)?

    With frameworks such as Angular, React, or Vue.js being very popular, one of the most requested features for Web Analytics was supporting single-page applications (SPA).

    SPAs work differently from a standard web application or website because they don’t load a new page every time there’s user interaction. Instead, they dynamically rewrite the current web page with new data retrieved from the web server.

    Since we’ve previously collected metrics only when the page load event is triggered, we had to change the transmission and interpretation of the signals from our JavaScript snippet to include sending metrics whenever there are any route changes made by the application or the website.

    We are happy to announce that we successfully implemented SPA support and enabled it for all customers.

    How we are supporting SPAs

    You might have noticed that some websites keep the # in the URL whenever you navigate their webpages. You would see URLs like the following:

    https://cloudflare.com/#blog
    https://cloudflare.com/#marketing
    

    The portion separated by the # is called a fragment, and based on the fragment changes, SPAs dynamically pull the resources to rewrite the webpage. That is how it was done before the HTML 5 History API was introduced and widely used. These days most SPA libraries/frameworks use HTML 5 History API to keep your UI in sync with the URL instead of using # (although, some still support #-based routers). In most cases you won’t easily notice a SPA by looking at the URL path.

    To support analytics for SPAs, we implemented sending additional payloads to the beacon endpoint, which collects the data for analytics, whenever we detect any changes to the state of the History API. The JavaScript snippet overrides the pushState method and listens to the onpopstate event. By tracking the History API’s state, you’ll now see the route changes in SPAs within the Web Analytics dashboard.

    Some older SPA libraries/frameworks still support hash-based routers. If your application or website is using a hash-based router, unfortunately it is not yet supported in Web Analytics. However, this is our initial launch to support SPAs, so stay tuned for any improvements and updates.

    How can I add my Single Page Application to Web Analytics?

    Select “Enable measuring single-page application” during the onboarding process. This will set up your site and the JavaScript snippet that enables the SPA feature. It is important to install the JavaScript snippet that has been set up for SPA. You will be able to identify the correct snippet by verifying whether it has `”spa”: true` in the data attribute used in the tag.

    Enhancing privacy-focused Web Analytics to better meet your metrics needs

    You can also change your existing site to be configured as SPA via “Manage Site,” which requires the deployment of a new JavaScript snippet. While this won’t change the site token, without the updated snippet Cloudflare won’t be able to measure the route change event.

    Core Web Vitals are now available for every Web Analytics customer

    Core Web Vitals is an initiative by Google to provide unified guidance for quality signals that are essential to delivering a great user experience on the web.

    In September 2020, we introduced Web Vitals for customers using Browser Insights, and many customers love getting those unique insights into their website performance. But we were also aware that Browser Insights wasn’t available to all our Web Analytics customers simply because they’re not able to onboard to the rest of Cloudflare for Infrastructure. Specifically, they’re not able to change their DNS servers.

    So today, we’re introducing Core Web Vitals to Web Analytics as well.

    You can see the Core Web Vitals metrics in the same dashboard as Visits and Page Views and check how healthy your website performance is.

    Enhancing privacy-focused Web Analytics to better meet your metrics needs

    What’s next

    This is just the start for our privacy-first Web Analytics.

    We’re excited to integrate more closely with the rest of Cloudflare and give customers even more detailed stats about performance and security (not just traffic). We’re also hoping to make our analytics even more powerful as a standalone product by building support for alerts, real-time updates, and more.

    Please let us know if you have any questions or feedback, and happy measuring!

    Source:: CloudFlare