Forum Moderators: martinibuster

Message Too Old, No Replies

Media.net ssl compliant code.

What's the proper code to use?

         

Broadway

3:28 pm on Oct 14, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm in the process of getting a site ready for the switch from all http to all https.
I'm serving Adsense and Media.net ads on the site. I know Adsense code is SSL compliant. I have read that media.net ads can be SSL compliant too, if the correct code is used.

I've emailed my media.net representative and also their general support email address but 3 days in I still haven't gotten a response (possibly I'm being punished for complaining about auto-start flash ads they were dumping on my site).

Anyway, here's the code I'm using. I see the reference to SSL in it but am unsure how to read the code and know what it does precisely.

I'm using this piece of code in the html <head> of my pages:

<script type="text/javascript">
window._mNHandle = window._mNHandle || {};
window._mNHandle.queue = window._mNHandle.queue || [];
medianet_versionId = "xxxxxx";
(function() {
var sct = document.createElement("script"),
sctHl = document.getElementsByTagName("script")[0],
isSSL = 'https:' == document.location.protocol;
sct.type = "text/javascript";
sct.src = (isSSL ? 'https:' : 'http:') + '//contextual.media.net/dmedianet.js?cid=xxxxxxxxx' + (isSSL ? '&https=1' : '')+'';
sct.async = "async";
sctHl.parentNode.insertBefore(sct, sctHl);
})();
</script>

-----
I'm using this code in the html <body> to call individual ads:

<div id="xxxxxx">
<script type="text/javascript">
try {
window._mNHandle.queue.push(function () {
window._mNDetails.loadTag("xxxxxx", "300x250", "xxxxxxx");
});
}
catch (error) {}
</script>
</div>
</div>

I looked at the page-load "waterfall" for one page that has media.net on it (as it is served now in http).
Some of the media.net resources were not https but I don't know how might be affected when my website switches to https:.
This is my "money" site and I'm hesitant to just make the switch and see what happens.
I don't want to serve pages all weekend with a browser "unsecure" warning showing.
Thanks.

levo

4:09 pm on Oct 14, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



isSSL = 'https:' == document.location.protocol

This line checks the protocol of the current page

sct.src = (isSSL ? 'https:' : 'http:') + '//contextual.media.net/dmedianet.js?cid=xxxxxxxxx' + (isSSL ? '&https=1' : '')+'';

This line sets the protocol as https, if the current page is using https. You should be safe.

Broadway

7:17 pm on Oct 14, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks levo I really appreciate it. I wanted to move on with this over the weekend but was hesitant to until it seemed all was in order.

Broadway

7:20 pm on Oct 18, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Unbelievable. I contacted Media.net email support three distinct times (twice my "rep" and once the generic support email) about this topic and got ZERO response.

On the day I switched to https, the targeting of my ads was horrible (I assumed because a https version of an old page was a "new" URL and had to be crawled before targeting could occur). As a result my daily income fell. By the day after I received an email from my rep asking if I could explain what changes might account for the drop. Previously they hadn't been the least bit motivated to help me make an improvement with my site or help to insure that it went smoothly. The only thing that motivated them to email me was a drop in revenue production. Super people.