My website will be used as an iframe on another website. My intention is to create a variable on google tag manager that will detect if the traffic I'm receiving is coming from a normal source or from a website with my iframe on it. I came up with this, but I don't think it could be correct.
function inIframe () {
try {
return window.self !== window.top;
} catch (e) {
return true;
}
}