Synthetic Classic has reached end of support and is no longer available. Existing Synthetic Classic customers have been upgraded to the all-in-one Dynatrace software intelligence platform.

Event hooks

Event hooks allow for event interception in the browser agents.

When an event hook is added to a test using addEventHook, the agents will start to listen to either the request or reply events that take place immediately after the hook is in place, up until the point in the script where a removeEventHook action is present, or until the end of the script if the hook is not removed.

The event hook action is appropriate to use if the script requires header customization prior to sending a request; for example, if you want to remove or replace specific headers that the browser agent normally sends.

Event Hook details are currently not exposed in the Recorder. Event Hook details can be added or edited if the script is saved locally as JSON and modified in a text editor.

The following event hook actions are available:

  • addEventHook

  • removeEventHook


The addEventHook action adds an event hook or listener to the transaction.

It takes the following parameters:


Defines which event the agent is expected to intercept. Two event types are available:

  • sendingRequest

    The sendingRequest event type tells the agent to listen to all outbound HTTP requests made by the agent. This is typically used when the script requires outbound HTTP requests to be modified before the agent makes them (for example, a custom header needs to be sent with a request).

  • replyReceived

    The replyReceived event type tells the agent to listen to all inbound HTTP responses. This is typically used when the script needs to capture or verify either the header or the content of an inbound request.

APIs are available for sendingRequest and replyReceived. For more information, see Recorder API.


Unique identifier for the event hook. The name can be any string value. It becomes useful if the script needs to identify the event hook later in order to remove it.


JavaScript function that tells the agent what to do while listening to the requests or responses taking place. Typically, the handler will include a conditional statement to identify which object request(s) or response(s) to intercept, and then what to do, once the event is intercepted.

The following is example JSON syntax for addEventHook.

  "type": "addEventHook",
  "name": "simpleHook",
  "eventType": "sendingRequest",
     "var headers = request.getHeaders();"+
     "headers.add('Myheader', 'test');"


The removeEventHook action removes the listener for a specified event hook.

This action takes one property:


The same name value assigned in the addEventHook action.

The following is example JSON syntax for removeEventHook.

  "type": "removeEventHook",
  "name": "simpleHook",