Direct download links from Design Studio Assets via redirect | Community
Skip to main content
C_Blakeley
New Participant
January 30, 2024
Solved

Direct download links from Design Studio Assets via redirect

  • January 30, 2024
  • 1 reply
  • 2961 views

Hello Community, 

 

I am hoping to reach out to @SanfordWhiteman to firstly say thank you for your endless support and contribution here. Its invaluable for me as a Marketo novice user. 

 

I am trying to implement your awesome blog for creating a redirect that will allow for direct links to a design studio asset: Stop using direct download links (unless you want to lose tracking!) — TEKNKL :: Blog

 

I am using a Marketo LP for the redirector page and trying to connect this with a Design Studio PDF file. 

I have added the code from here: MktoLP :: Redirect Page v1.0.2 (codepen.io) and then added the asset URL to the LP URL (see S/S attached)

 

As you'll see in the S/S I am seeing 'Asset URL not found' and hoped you could help me troubleshoot? 

 

Landing Page Template HTML: 

 

<!DOCTYPE html> <html> <head> (function(redirectTarget){ var allowedOrigins = [ 'https://s.codepen.io', 'https://codepen.io', 'http://example.com' ], // which domains are allowed for redirection redirectMs = 3500, // how long before redirecting progressMs = 500, // how long between updates of the "progress meter" progressChar = '&bull;', // progress character (HTML bullet) errNoAsset = 'Asset URL not found.', // message when no asset in hash errInvalidAsset = 'Asset URL not allowed.', // when asset not our domain progress = setInterval(function(){ if (redirectTarget) { document.body.insertAdjacentHTML('beforeend',progressChar); } else { clearInterval(progress), clearTimeout(redirect); document.body.insertAdjacentHTML('beforeend',errNoAsset); } }, progressMs), redirect = setTimeout(function(){ var redirectLoc = document.createElement('a'); redirectLoc.href = redirectTarget; redirectLoc.origin = redirectLoc.origin || [redirectLoc.protocol, '//', redirectLoc.hostname, ['http:','http:80','https:','https:443'] .indexOf(redirectLoc.protocol+redirectLoc.port) != -1 ? '' : ':' + redirectLoc.port ].join(''); clearInterval(progress); if (allowedOrigins.indexOf(redirectLoc.origin) != -1) { document.location.href = redirectTarget; } else { document.body.insertAdjacentHTML('beforeend',errInvalidAsset); } }, redirectMs); })(document.location.hash.substring(1)); <meta charset="utf-8"> <title></title> <script type="text/javascript"> document.write(unescape("%3Cscript src='//munchkin.marketo.net/munchkin-beta.js' type='text/javascript'%3E%3C/script%3E")); </script> <script> Munchkin.init('308-OXI-896'); // your Munchkin ID and options, obviously! </script> <script> (function(redirectTarget){ var allowedOrigins = [ 'https://info.ai.baesystems.com', 'https://www.baesystems.com', 'https://baesystems.com' ], // which domains are allowed for redirection redirectMs = 3500, // how long before redirecting progressMs = 500, // how long between updates of the "progress meter" progressChar = '&bull;', // progress character (HTML bullet) errNoAsset = 'Asset URL not found.', // message when no asset in hash errInvalidAsset = 'Asset URL not allowed.', // when asset not our domain progress = setInterval(function(){ if (redirectTarget) { document.body.insertAdjacentHTML('beforeend',progressChar); } else { clearInterval(progress), clearTimeout(redirect); document.body.insertAdjacentHTML('beforeend',errNoAsset); } }, progressMs), redirect = setTimeout(function(){ var redirectLoc = document.createElement('a'); redirectLoc.href = redirectTarget; redirectLoc.origin = redirectLoc.origin || [redirectLoc.protocol, '//', redirectLoc.hostname, ['http:','http:80','https:','https:443'] .indexOf(redirectLoc.protocol+redirectLoc.port) != -1 ? '' : ':' + redirectLoc.port ].join(''); clearInterval(progress); if (allowedOrigins.indexOf(redirectLoc.origin) != -1) { document.location.href = redirectTarget; } else { document.body.insertAdjacentHTML('beforeend',errInvalidAsset); } }, redirectMs); })(document.location.hash.substring(1)); </script> <style> body {background:#fff;} </style> </head> <body> </div> </body> </html>

 

Landing Page URL with Asset URL:

 

https://info.ai.baesystems.com/World-Defense-Show-Brochure-2024.html#https://info.ai.baesystems.com/rs/308-OXI-896/images/KSA_Brochure_2024.pdf?

 

 

Thank you 

Cathy 

 

Best answer by SanfordWhiteman

Also, you don't need to have a "?" at the end if you don't have any query parameters!https://info.ai.baesystems.com/World-Defense-Show-Brochure-2024.html#https://info.ai.baesystems.com/rs/308-OXI-896/images/KSA_Brochure_2024.pdf

(Also a ? after the hash doesn’t start a query string, it’s part of the hash!)

1 reply

Darshil_Shah1
Community Manager
January 30, 2024

@c_blakeley, this works for me! I can get to the PDF from the URL you mentioned in the question, and I also saw the visitWebpage Munchkin hit in the browser's network activity. Also, you don't need to have a "?" at the end if you don't have any query parameters!

 

https://info.ai.baesystems.com/World-Defense-Show-Brochure-2024.html#https://info.ai.baesystems.com/rs/308-OXI-896/images/KSA_Brochure_2024.pdf

 

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
January 30, 2024

Also, you don't need to have a "?" at the end if you don't have any query parameters!https://info.ai.baesystems.com/World-Defense-Show-Brochure-2024.html#https://info.ai.baesystems.com/rs/308-OXI-896/images/KSA_Brochure_2024.pdf

(Also a ? after the hash doesn’t start a query string, it’s part of the hash!)