Prevent domain script from executing on specific landing pages

  • 8 August 2017
  • 6 replies
  • 81 views

Badge

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 ? 🙂

Thank you all!


6 replies

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.

Userlevel 7
Badge +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

Badge

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

Userlevel 3

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!

Badge

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

Noob question. Im running into this issue, Im not a developer so im having some difficulty in solving this. What is GMT?

Also the script, I can add it in the manager?

I have to add page IDs, how do I find page ID of the popup Lightbox and the “Form Confirmation Dialogue”?

Do I add the script, with all the IDs inside in the script manager and then in the HEAD section or BODY?

Cheers,
Luuk

Reply