# Cookie while triggering on-demand execution of browser click-path

**URL:** <https://community.dynatrace.com/t/cookie-while-triggering-on-demand-execution-of-browser-click-path/45271>\
**Category:** Synthetic Monitoring\
**Tags:** browser-monitors, synthetic-monitoring, private-synthetic-locations\
**Created:** [April 23, 2024, 7:59pm UTC](https://community.dynatrace.com/t/cookie-while-triggering-on-demand-execution-of-browser-click-path/45271 "2024-04-23T19:59:23Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![AK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/ak/32/164_2.png) [@AK](https://community.dynatrace.com/u/AK)\
**Post date:** [April 23, 2024, 7:59pm UTC](https://community.dynatrace.com/t/cookie-while-triggering-on-demand-execution-of-browser-click-path/45271/1 "2024-04-23T19:59:23Z")

</div>

Hi,

I’m triggering on-demand execution for one of our browser click-path monitor.&nbsp;Use case is to pass another navigation URL and associated new cookie. The way to achieve this is by adding customized script with event and cookie.

I’m able to pass the navigate event but how do I pass cookie in request body. I tried to add cookie like below but that didn’t worked.

```markup
{
    "processingMode": "EXECUTIONS_DETAILS_ONLY",
    "failOnPerformanceIssue": true,
    "failOnSslWarning": true,
    "stopOnProblem": true,
    "takeScreenshotsOnSuccess": true,
    "monitors": [
        {
            "customizedScript": {
                "events": [
                    {
                        "type": "navigate",
                        "url": "https://test.xyz.com",
                    }
                ],
                "cookies": [
                    {
                        "domain": "test.xyz.com",
                        "name": "client",
                        "path": "/summary",
                        "value": "abcdefghijklmnopqrstuvwxyz="
                    }
                ]
            },
            "monitorId": "SYNTHETIC_TEST-bhb439dhco2cc",
            "locations": [
                "SYNTHETIC_LOCATION-abcdsjao932ue2"
            ]
        }
    ]
}

```

Error is,

```markup
{
    "error": {
        "code": 400,
        "message": "Script validation failed: {\"violations\":[{\"path\":\"/cookies/0\",\"message\":\"Illegal property \\\"cookies/0\\\"\"}]}"
    }
}

```

Need help here.

Regards,

AK

---

<div class="post-metadata">

**Author:** ![erh\_inetum](https://avatars.discourse-cdn.com/v4/letter/e/48db29/32.png) [@erh\_inetum](https://community.dynatrace.com/u/erh_inetum)\
**Post date:** [April 24, 2024, 5:20am UTC](https://community.dynatrace.com/t/cookie-while-triggering-on-demand-execution-of-browser-click-path/45271/2 "2024-04-24T05:20:24Z")

</div>

Hi&nbsp;[@AK](https://community.dynatrace.com/user/2080)&nbsp;,

Have you tried setting the cookie in the “Advanced Settings” settings and tested if it works?

 ![erh_inetum_1-1713936068775.png](https://global.discourse-cdn.com/dynatrace/original/3X/5/4/545f2fdac9cc6bae97b772e8bb0cc80ebbe28e35.png)

Regards,

Elena.

---

<div class="post-metadata">

**Author:** ![AK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/ak/32/164_2.png) [@AK](https://community.dynatrace.com/u/AK)\
**Post date:** [April 24, 2024, 5:53am UTC](https://community.dynatrace.com/t/cookie-while-triggering-on-demand-execution-of-browser-click-path/45271/3 "2024-04-24T05:53:55Z")

</div>

[@erh\_inetum](https://community.dynatrace.com/user/40722), thank you for your response.

Cookie is already added under advance setup for&nbsp;  
[firsttest.xyz.com](http://firsttest.xyz.com) domain

However, I want to trigger on-demand for another domain

i.e. [test.xyz.com](http://test.xyz.com)

This would be having different cookie value.

What I need a help with how can we pass the cookie in request body for on-demand execution?

Regards,

AK

---

<div class="post-metadata">

**Author:** ![PacoPorro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pacoporro/32/36087_2.png) [@PacoPorro](https://community.dynatrace.com/u/PacoPorro)\
**Post date:** [April 24, 2024, 6:30am UTC](https://community.dynatrace.com/t/cookie-while-triggering-on-demand-execution-of-browser-click-path/45271/4 "2024-04-24T06:30:50Z")

</div>

Take a look on this&nbsp;[Browser clickpath events in Classic — Dynatrace Docs](https://docs.dynatrace.com/docs/shortlink/id-brower-clickpath-events#javascript)  
Not sure if this can help.

---

<div class="post-metadata">

**Author:** ![AK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/ak/32/164_2.png) [@AK](https://community.dynatrace.com/u/AK)\
**Post date:** [April 24, 2024, 2:45pm UTC](https://community.dynatrace.com/t/cookie-while-triggering-on-demand-execution-of-browser-click-path/45271/5 "2024-04-24T14:45:50Z")

</div>

[@PacoPorro](https://community.dynatrace.com/user/40713),

Thanks for the response. However, I would need help in passing cookie while triggering on-demand synthetic execution via API

Regards,

AK

---

<div class="post-metadata">

**Author:** ![AK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/ak/32/164_2.png) [@AK](https://community.dynatrace.com/u/AK)\
**Post date:** [April 25, 2024, 11:32am UTC](https://community.dynatrace.com/t/cookie-while-triggering-on-demand-execution-of-browser-click-path/45271/6 "2024-04-25T11:32:30Z")

</div>

Any clue on this guys,

Basically, I’m looking to add cookies which we add under advanced setup. This can be seen under configuration section when we go script mode of synthetic monitor like below,

 ![AK_0-1714044666864.png](https://global.discourse-cdn.com/dynatrace/original/3X/f/9/f947e10fe7572102f811405ada84aae71cef662d.png)

Regards

AK

---

<div class="post-metadata">

**Author:** ![AK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/ak/32/164_2.png) [@AK](https://community.dynatrace.com/u/AK)\
**Post date:** [April 25, 2024, 5:15pm UTC](https://community.dynatrace.com/t/cookie-while-triggering-on-demand-execution-of-browser-click-path/45271/7 "2024-04-25T17:15:55Z")

</div>

[@HannahM](https://community.dynatrace.com/user/1433),

Is it something that is achievable?

Regards,

AK

---

<div class="post-metadata">

**Author:** ![hannahmac](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/hannahmac/32/41823_2.png) [@hannahmac](https://community.dynatrace.com/u/hannahmac)\
**Post date:** [April 26, 2024, 9:46am UTC](https://community.dynatrace.com/t/cookie-while-triggering-on-demand-execution-of-browser-click-path/45271/8 "2024-04-26T09:46:16Z")

</div>

The script configuration section cannot be customized. The list of events that can be&nbsp;customized can be found [here](https://docs.dynatrace.com/docs/platform-modules/digital-experience/synthetic-monitoring/general-information/on-demand-executions#api) but you can customize a cookie step, so you could add a cookie event to the monitor and then modify that on the fly.

---

<div class="post-metadata">

**Author:** ![AK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/ak/32/164_2.png) [@AK](https://community.dynatrace.com/u/AK)\
**Post date:** [April 26, 2024, 12:13pm UTC](https://community.dynatrace.com/t/cookie-while-triggering-on-demand-execution-of-browser-click-path/45271/9 "2024-04-26T12:13:54Z")

</div>

[@HannahM](https://community.dynatrace.com/user/1433), thanks for confirmation.

Regards,

AK

---

<div class="post-metadata">

**Author:** ![AK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/ak/32/164_2.png) [@AK](https://community.dynatrace.com/u/AK)\
**Post date:** [April 28, 2024, 7:12pm UTC](https://community.dynatrace.com/t/cookie-while-triggering-on-demand-execution-of-browser-click-path/45271/10 "2024-04-28T19:12:57Z")

</div>

Well I’m able to get workaround on this.

As we cannot pass the configuration section during on-demand execution, we can remove the cookies added from advance section of browser click-path and add ‘cookie’ event under recorded click-path and we are good to pass the values during on-demand execution. Below is the request body I used successfully.

```markup
{
    "processingMode": "EXECUTIONS_DETAILS_ONLY",
    "failOnPerformanceIssue": true,
    "failOnSslWarning": true,
    "stopOnProblem": true,
    "takeScreenshotsOnSuccess": true,
    "monitors": [
        {
            "customizedScript": {
                "events": [
                    {
                        "type": "navigate",
                        "url": "https://test.xyz.com"
                    },
                    {
                        "type": "cookie",
                        "cookies": [
                            {
                                "domain": "test.xyz.com",
                                "name": "client",
                                "path": "/profileV2",
                                "value": "abcdefghijklmnopqrstuvwxyz="
                            }
                        ]
                    }
                ]
            },
            "monitorId": "SYNTHETIC_TEST-bhb439dhco2cc",
            "locations": [
                "SYNTHETIC_LOCATION-abcdsjao932ue2"
            ]
        }
    ]
}

```

Hope this is helpful.

Regards,

AK
