Hello EveryOne! I have a script tag with some cust...
# suitecommerce
z
Hello EveryOne! I have a script tag with some custom code in a header template file. I want this script to trigger on every page except the PDP (Product Detail Page). How can I achieve this?
m
do you have Google Tag Manager on your account installed?
z
No i don't have
s
Putting a script tag in a template file is generally not a good practice. You should put your JavaScript in the view or entry point file. With that aside, it is relatively easy to track whether you are on a PDP by analysing what the current view is and using the
instanceof
operator to test whether it's using a particular prototype
Using my browser's developer console, I can do something like this:
Copy code
SC.Application.getLayout().getCurrentView() instanceof require(SC.Application.getComponent('PDP').DEFAULT_VIEW)
It returns
true
on PDPs, and
false
everywher else