I have the following code on a development page. (Sorry it's inaccessible.) The query parameters on the page are: ?trackid=209B139A-A3BD-4AF0-A596-6248A9F3091C&cat=fafsa%20application
I am expecting to have the value for catKey returned as "fafsa application" but I get the following error in my console:
Uncaught TypeError: Cannot read property 'split' of undefined
Part of the problem is that in most cases, the cat parameter won't be the last one, so I have to split it again on the next ampersand. Because there is not another one, I'm pretty sure that's causing the error. I need to cover all scenarios including this example. But I think there's also something wrong with my syntax or the if-then-else statement.
Hoping one of you will easily tell me what I'm doing wrong.
<script type='text/javascript'>
function catKey() {if (window.parent.location.search.split('cat=')[1] !== null) {decodeURIComponent(window.parent.location.search.split('cat=')[1].split('&')[0]);} else {}};
var _eaq = _eaq || [];
var a = {
'RenderingDiv': 'div-gpt-ad-1439558353478-0', //Id of the element which you want the Ads to render (Required)
'AdServer': 'DFP', //The Ad Server (Optional: defaults to DFP)
'Sizes': [960, 1600], //The Ad Sizes which are normally added in the head (Required for Double Click Ads)
'AdUnitPath': '/59026966/Exit_Pop', //The Ad unit Value which is normally added in the head (Required for Double Click Ads)
'Vendor': 'VENDOR1', //The Vendor Name (Optional: VANTAGE default)
'IsWizard': true, //if IsWizard is true, you can add below line
'AddiTargetingParam': {
'domain': window.parent.location.hostname, //targets the domain
'landingpage': window.parent.location.pathname.split('/')[2], //targets the landing page directory name
'step': window.parent.location.href.split('#')[1], //targets the step
'trackid': document.cookie.split('_CampaignTrackID=')[1].split(';')[0], //pulls trackid out of cookie
'exclusive_id': document.cookie.split('_CampaignTrackID=')[1].split(';')[0], //pulls trackid out of cookie
'exclusive': window.parent.location.search.split('exclusive=')[1], //pulls exclusive out of url
'cat': catKey(),
},//Customized additional targeting parameters
};
_eaq.push(a);
</script>
Aucun commentaire:
Enregistrer un commentaire