Should I use protocol-relative URLs in ad tags?Ad tags can be placed in many areas of a website: some secure areas and some non-secure areas. However, non-secure content can be blocked by the browser when the web page is secure. The error message in Internet Explorer is "This Page Contains Both Secure and Non-Secure Items. Do you want to display the nonsecure items?" Other browsers can simply ignore and skip the non-secure content. This means a non-secure ad might not display within a secure website. This is one of the common sources for data discrepancy if there are multiple ad servers involved in tracking the same ad impression.
Therefore, it's better to use the same protocol for all URL requests, either all
"http://" or all
"https://". Ideally, you should use SSL/https for all requests. For ad serving, it means using the secure ad serving tag on secure sites and the non-secure ad serving tag on non-secure sites. To do this, you can manually match the correct ad tag with your website's area. For example: a non-secure ad tag for the homepage and a secure ad tag for the login area. However, you can use protocol-relative URLs, also called scheme-relative URLs or network-path references.
<iframe src="http://g.adspeed.net/ad.php..."> <a href="http://g.adspeed.net/ad.php..."><img src="http://g.adspeed.net/ad.php..."/></a> </iframe>or this ad serving tag for secure web pages:
<iframe src="https://g.adspeed.net/ad.php..."> <a href="https://g.adspeed.net/ad.php..."><img src="https://g.adspeed.net/ad.php..."/></a> </iframe>You can use a protocol-relative URL that has auto-detection and auto-switching:
<iframe src="//g.adspeed.net/ad.php..."> <a href="//g.adspeed.net/ad.php..."><img src="//g.adspeed.net/ad.php..."/></a> </iframe>
ConsiderationsThis setup can be applied to other URLs, not just our ad serving tags. However, there are several considerations you need to know before you convert all URLs to this format:
- The SSL certificate needs to be valid and working for the same domain as the non-secure/standard domain. If you have SSL on a different domain or sub-domains then this scheme will not work. For example:
- Really old browsers might not support, understand or properly handle this protocol-relative URL format. Potential issues with these older browsers include double-download of the same file and missing file error
- Some email software converts protocol-relative URLs to
"file://"URLs and try to look in a folder on the client's computer, which likely does not exist. This also happens when you view the web page locally after downloading it.
Other Articles in Ad Tag
- Accelerated Mobile Pages Project - AMP Ad Tag
- Can I have ads refresh automatically without a page reload?
- How can I avoid document.write warning in Chrome?
- How can I avoid duplicate ads on the same page?
- How can I combine multiple ads in the same placement?
- How can I defer ads until after the page has finished loading?
- How can I display an ad only when it is visible on screen?
- How can I measure ad viewability?
- How can I mix ad dimensions or mix banners with text-link ads?
- How can I put ads into my blog/website?
- How can I serve multiple ad dimensions in the same place?
- How can I serve multiple zones with a single server request?
- How can I support click tracking for external ad servers?
- How can I turn off ad serving error messages?
- How do I add current timestamp into the serving code?
- How do I display mobile ads using Android WebView?
- How do I display mobile ads using Apple iOS WKWebView?
- How do I integrate AdSpeed mobile ad serving API?
- How do I make ads responsive on mobile devices?
- How do I pass custom data and variables into the ad?
- How do I set up advertising on WordPress?
- How do I setup a companion ad in video ad serving?
- How do I setup a passback ad tag?
- How do I switch to secure SSL/https ad serving?
- What are custom ad serving settings and variables?
- What are different formats of serving code?
- What are different types of ad tag?
- What are the effects of ad blocking software?
- What is the pop-up and pop-under ad tag?
- What is the serving code or ad tag?
- What is WMODE for SWF ads? How can I change it?
- Where is the publisher-side file for iframe busting?
- Why doesn't the provided HTML serving code work?
Cannot find an answer for your question? Ask our Customer Care team
- How do I switch to secure SSL/https ad serving?
"If your site is moving from regular HTTP to SSL/HTTPS, all components and URLs, including ads, should also be switched ..."
- Secure Ad Serving with SSL
"We support both regular and secure ad serving. Secure ad serving through SSL (Secure Sockets Layer, https://) uses 256-bit high-grade ..."
"Documentation for API methods to manage your campaigns in our ad server. API Version1.3.7 (build 20200318). This page was updated ..."
"Documentation for API methods to manage one or multiple channels. API Version1.3.7 (build 20200318). This page was updated on Tue, ..."
- How secure is my credit card information?
"You can subscribe to our ad serving service with your credit card or pay through PayPal. We understand security is ..."