Knowledge Base

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I set a custom page name for an AJAX call using JavaScript Agent?

I have got a couple of queries on whether we can set the custom page name for AJAX events or not. The documentation around it is a bit confusing (but we will get that sorted out very soon) but we can set custom page names for AJAX call as well.

 

You need to use 'userPageName' attribute in window['adrum-config'] > userEventInfofor the AJAX event. Very much similar to the 'PageView' event config shown in the link below.

https://docs.appdynamics.com/display/PRO43/Add+Custom+User+Data+to+a+Page+Browser+Snapshot

 

The example to set the custom page name for AJAX event would be:

<head>
...
...
<script>
	window['adrum-start-time'] = new Date().getTime();
	window['adrum-config'] = {
            userEventInfo: {
                "Ajax" : function(context) {
                    return {
                    	userPageName: "Search"
                    }
                }
            }
        };
...
...
	(function(config){
	    config.appKey = 'YOUR-EUM-APP-KEY';
	    config.adrumExtUrlHttp = 'http://cdn.appdynamics.com';
	    config.adrumExtUrlHttps = 'https://cdn.appdynamics.com';
	    config.beaconUrlHttp = 'http://col.eum-appdynamics.com';
	    config.beaconUrlHttps = 'https://col.eum-appdynamics.com';
	    config.xd = {enable : false};
	})(window['adrum-config'] || (window['adrum-config'] = {}));
...
...
</script>
</head>

This will name all the AJAX events as 'Search' but you can use JS conditions to set it whatever based on the context.url value.

 

Things to be noted here are:

- This config(in bold) should go before the js agent instrumentation code.

- This config works v4.3 JS Agent onwards.

 

Hope this will help.

Version history
Revision #:
5 of 5
Last update:
4 weeks ago
Updated by:
 
Labels (1)
Tags (2)
0 Kudos