Prevent domain script from executing on specific landing pages


#1

Hey there!

We run a domain-wide script for our Chat bot, but I’d like to try a Multi-Step form workaround that requires another page’s URL to open in a Lightbox. It all seems to work except that the chat also appears in the lightbox making things look strange and possibly giving a poor UX if accidentally clicked/tapped.

I noticed Noah’s recent victory with multi-step forms but we need multiple fields at this stage so it’s not quite suitable for us yet. I ran into a topic almost identical to this (How to stop domain-wide global JavaScript from executing on specific landing pages) but neither user on the thread seems to be active and the actual answer from OP is missing or the code is stripped and the other answer doesn’t really have any explanation.

I did stumble on documentation here (http://documentation.unbounce.com/hc/en-us/articles/203879070) explaining that you can hone in on a page’s id and I assume this would be part of the answer but I think a combination of lack of coffee, limited JS knowledge and impatience means I haven’t been able to nut it out yet.

I didn’t want to waste too much fiddling around if someone far more clever can point me in the right direction!
Does anyone have an answer to help me out with this one please ? :slight_smile:

Thank you all!


#2

Hey @CeeBick!

Actually, our awesome support coach @Vic was working on something very similar. I’ll ping him and see if he ended up building this solution out.


#3

Hi @CeeBick,

A somewhat quick and more clean solution would be to use GTM to fire the Chat script only on the pages you want, excluding lightboxes.

Best,
Hristian


#4

Hey Hristian,

This is a very simple alternative! It didn’t even click as we haven’t got our GTM container on our unbounce pages (yet), but it definitely makes sense to do it that way.

Cheers,
Chloe


#5

Hi @CeeBick

I agree with Hristian and I like his suggestion of using GTM to fire the chat script only in the pages you need it, but as Justin mentioned, I do have a script to exclude certain pages from a script added through the Script Manager.

I will be writing a tutorial on how to use it soon, but here it is in case you want to give it a go: https://gist.github.com/victorzen/c5aae1a5880fe2be79a92776ee040d7a

All you need to do is replace my page IDs for the IDs of the pages you need to exclude and add your script where it says //ADD YOUR SCRIPT HERE.

You can find the ID of your page in the URL of its overview: https://www.screencast.com/t/oonjWEa5HdRv

Hope you find it useful if you decide to give it a go and let me know if you have any comments or questions. Remember you can also reach me by sending an email to support@unbounce.com in attention to Victor.

All the best, Chloe!


#6

Hi Vic,

Thank you for this, it’s a great help!
Given that this particular case will only be a test to see how things go and probably only applied to one page, I think I’ll give your script a whirl!
If it looks like it will be something we’ll implement over more than one page we’ll probably implement GTM.

Thank you both for your time, @Vic and @Hristian!

Cheers