# How to implement the File Download action on Browser click path monitor with help of JavaScript Event

**URL:** <https://community.dynatrace.com/t/how-to-implement-the-file-download-action-on-browser-click-path-monitor-with-help-of-javascript-event/39204>\
**Category:** Troubleshooting\
**Tags:** browser-monitors, synthetic-monitoring\
**Created:** [April 11, 2023, 2:18pm UTC](https://community.dynatrace.com/t/how-to-implement-the-file-download-action-on-browser-click-path-monitor-with-help-of-javascript-event/39204 "2023-04-11T14:18:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mareeswaran](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@Mareeswaran](https://community.dynatrace.com/u/Mareeswaran)\
**Post date:** [April 11, 2023, 2:18pm UTC](https://community.dynatrace.com/t/how-to-implement-the-file-download-action-on-browser-click-path-monitor-with-help-of-javascript-event/39204/1 "2023-04-11T14:18:07Z")

</div>

As we aware, Synthetic Browser Click path monitor doesn’t support for File Download actions. However, with help of JavaScript Event, we can perform the same action.

You can follow the below steps,

1. We need to get the Fiddler session which should contain the Downloaded HTTP request and response details

2. Check if the Downloaded HTTP request URL, headers and post data is static or dynamic

3. If it is static then we can use the same data and will create a fetch or XMLHttpRequest JavaScript method and insert this code into the JavaScript Event of your Browser click path monitor

4. If it is dynamic data then we need to get this values from the HTML source code of that page or cookies or some times we need to send the request to the server to get those values. Based on that we need to create a fetch or XMLHttpRequest JavaScript method and insert this code into the JavaScript Event of your Browser click path monitor.

You can find the sample JavaScript code which we can perform the File Download action

```auto
api.startAsyncSyntheticEvent();
var tempToken;
var tempTokenrequesturl = "https://testing.com/services/tempToken?client=test&httpStatus=F&csfToken=csfToken&method=GET";
fetch(tempSessionTokenrequesturl, {
        "headers": {
            "accept": "application/xml, text/xml, */*; q=0.01",
            "accept-language": "en-US,en;q=0.9",
            "sec-ch-ua": "\"Google Chrome\";v=\"107\", \"Chromium\";v=\"107\", \"Not=A?Brand\";v=\"24\"",
            "sec-ch-ua-mobile": "?0",
            "sec-ch-ua-platform": "\"Windows\"",
            "sec-fetch-dest": "empty",
            "sec-fetch-mode": "cors",
            "sec-fetch-site": "same-origin",
            "x-requested-with": "XMLHttpRequest"
        },
        "referrer": "https://testing.com/web/",
        "method": "GET",
        "mode": "cors",
        "credentials": "include"
    }).then(response => response.text())
    .then(data => {
        api.info("tempToken Response " + data);
        var parser = new DOMParser();
        var xmlDOM = parser.parseFromString(data, "text/xml");
        var value = xmlDOM.getElementsByTagName("tempToken")[0].childNodes[0].nodeValue;
        tempToken = value;
        api.info(value);
        filedownloadcall();
    })
    .catch(err => api.fail(err));

function filedownloadcall() {
    var filedownloadurl = "https://testing.com/filename=test?wid=123&sid=456&did=789&tempToken=" + tempToken ;

    fetch(filedownloadurl, {
            "headers": {
                "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
                "accept-language": "en-US,en;q=0.9",
                "sec-ch-ua": "\"Google Chrome\";v=\"107\", \"Chromium\";v=\"107\", \"Not=A?Brand\";v=\"24\"",
                "sec-ch-ua-mobile": "?0",
                "sec-ch-ua-platform": "\"Windows\"",
                "sec-fetch-dest": "iframe",
                "sec-fetch-mode": "navigate",
                "sec-fetch-site": "same-origin",
                "upgrade-insecure-requests": "1"
            },
            "method": "GET",
            "mode": "cors",
            "credentials": "omit"
        }).then(response => response.text())
        .then(data => {
            api.info("File Download Response " + data);
            var filecontent = api.getValue("filecontent");
            if (data.indexOf(filecontent) >= 0) {
                api.info("File Download Success");
                api.finish();
            } else {
                api.fail("File Download Failed");
            }
        })
        .catch(err => api.fail(err));

}

```

 ![image4.png](https://global.discourse-cdn.com/dynatrace/original/3X/4/e/4eb2c088d55b54b4d44353bdaea781bcd151ce0b.png)

---

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [May 12, 2023, 6:58pm UTC](https://community.dynatrace.com/t/how-to-implement-the-file-download-action-on-browser-click-path-monitor-with-help-of-javascript-event/39204/2 "2023-05-12T18:58:28Z")

</div>

Thank you for sharing this! I’m sure it will help out many community members.

---

<div class="post-metadata">

**Author:** ![shivam\_mishra](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@shivam\_mishra](https://community.dynatrace.com/u/shivam_mishra)\
**Post date:** [May 25, 2026, 11:51am UTC](https://community.dynatrace.com/t/how-to-implement-the-file-download-action-on-browser-click-path-monitor-with-help-of-javascript-event/39204/3 "2026-05-25T11:51:30Z")

</div>

[@Mareeswaran](https://community.dynatrace.com/user/40562)&nbsp;I have a requirement where a file is downloaded through a Synthetic Browser Click Path monitor. The downloaded file is in **ZIP format** , and inside it we need to **validate specific content (search for a string)**.

I have a few concerns and would appreciate guidance:

1. **ZIP File Validation**  
Since the file is compressed, is it possible to:

2. **Private Location Execution & Storage Impact**  
This monitor will be executed every **5 minutes from a Private Location** , which means:
