Passing along a question I got from my web team -
We have a business requirement to track Marketo RTP dialog pop-up's LOAD and CLICK events. We are trying to achieve this by calling two java script functions of the parent window. But, it is not working and also pop-up stops loading on the page.
This is what we are trying to do -
- Call parent window's function on pop-up load - onLoadEventDatalayer(parentPageURL)
- Call parent window's function on pop-up click - onClickEventDatalayer(parentPageURL)
The actual code is like this -
<script>
var parentURL = window.parent.location;
$( document ).ready(function() {
if(typeof window.parent.onLoadEventDatalayer(parentURL) === 'function') {
window.parent.onLoadEventDatalayer(parentURL);
}
$('#trwDialog > div > a').click(function(){
if(typeof window.parent.onClickEventDatalayer() === 'function') {
window.parent.onClickEventDatalayer();
}
});
});
</script>
Can someone please help us to get this resolved or guide us about the implementation approach.
There is nothing inherently wrong with the way these functions are called. You wait for ready() and then do something, fine.
Neither I nor anybody else could tell you what happens after they're called.
This isn't the way to troubleshoot code -- your development team should know this. What could someone say about code when they only know the function name?
And you shouldn't change what you're passing to the functions if the developers say they expect a Location. Location.href is a String, not a Location.