Custom initial page load transaction namesedit

Correctly setting initial page load transaction names is vital to ensuring the best experience when viewing application performance metrics in the APM app.

Let’s look at an example to understand why. Here are a few URLs you might find on

// Blog Posts

// Documentation

By default, is set to Unknown. This means that when viewing transactions in the APM app, all transactions will be grouped under the common transaction name of Unknown. Grouping every transaction (especially unrelated ones) into one group doesn’t make much sense. To fix this, you can use the API to change the default initial page load transaction name with the pageLoadTransactionName configuration option.

A common (and easy) way to set transaction names, is to use the pageLoadTransactionName configuration option to set the transaction name to the page URL. However, this solution won’t be helpful as-is. Most URLs include unique names - like blog post titles, or query strings. As a result, you’ll end up with a large number of different transaction names. For this solution to work, you’ll need to strip away unique information and find commonality between your URLs. Looking at the URLs above, all blog posts have /blog/ in the URL, and all docs have /guide/ in the URL. We can use these paths to set the initial page load transaction names to either blog or guide. This process can then be expanded across your site to ensure common transactions are grouped correctly.

Based on our example URLs above, here’s a code snippet to illustrate this process:

var parts = window.location.pathname.split('/'); 
var pageName = window.location.pathname; 
if (parts.length > 0) {
    pageName = parts[1] 
    serviceName: "service-name",
    serverUrl: "server-url",
    pageLoadTransactionName: pageName 

Grab the URL path and split it

Set a default pageName

Set the pageName to the first part of the pathname (in this example: guide or blog)

Pass the pageName into the APM agent as a configuration option