Hi All,

We are running google tag manager javascript in all the pages this is because of the JavaScirpt Manager application that we are using. 

Now I would like to remove the script from one particular page. So i was wondering if i get to modify the HTML response in the preparation of the page. Did some search there is "AddPostProcessingFilter" server action but doesn't seem achieve my goal.


Another way is to load javascript dynamically, i can write a script to check the page name and then loading using $.getScript. I personally don't like this approach.


Any idea how this can be done in the server side (perparation) ?


Thank you

Hi Sujan, 

How are you running the Google tag manage Javascript in all the pages? 

Where are you putting this Javascript? 

In general I would put it in a block, so that I could enclose it in an IF and show or not depending on some condition. 

Alternatively you can add a Run JavaScript action to the preparation to send the a JavaScript back with the page to the browser, that will run and change the HTML. 

Cheers

Hi Eduardo,

thank you for the post.

How are you running the Google tag manage Javascript in all the pages?

We are using the this component from the forge JavaScript Manager. we just have to add the scripts tags and it will be automatically added to all the applications. We get to exclude applications so it will not add the scripts for those application. It doesnt allow us to configure page/web screen level.


Where are you putting this Javascript? 

It is being placed in Head Bottom, the JavaScript Manager allows us to specify the location of the script tag.


Regrading this

In general I would put it in a block, so that I could enclose it in an IF and show or not depending on some condition. 

Alternatively you can add a Run JavaScript action to the preparation to send the a JavaScript back with the page to the browser, that will run and change the HTML. 

Yup agreed. this will definitely solve the issue but we already have couple of applications implemented using the approach (JavaScript Manager) so for now prefer not to change the approach.


So it possible to modify the HTML response before sending it to the browser? My idea is to get the HTML response in the preparation, use regex and remove the google tag manager script. I just need to do it on one page. Any way of achieving this ?


Thank you.


Solution

Hi, 

Regarding changing the HTML DOM sent back, this is not possible from the preparation, as it seems the JavaScript you add with this application is not being added there or in the page, but automatically by the app when building the page. 

Don't know if there is anything you can do differently other than use the Run JavaScript action from HttpRequeatHandler, in preparation, with a Javascript that will trigger on page ready and remove/disable the add script... 

Solution

Thanks again, Eduardo.

Didn't have luck with other approaches too.

We decided to go with this approach for now as we are running out of time. 

We are adding javascript code in the JavaScript Manager application that will check the path name and load the script for all the pages except for this particular page. Might not be a good solution but for now it will solve the issue.


Thank you very much Eduardo for the prompt response. Really appreciate it.