Hi Elina,
If you want more control over exactly what happens when the Back button is pressed, you could use a Close page, Cancel or Show Page action on the button. If you really want to use window.history.go(-1); it would be best to call a nanoflow which calls a JavaScript action that implements the code. Note that the JavaScript action only needs to contain window.history.go(-1); line, the other things are not necessary by doing it this way.
Hope that helps!