I can't add any custom code, says it's wrong and is ignoring it?

I’m trying to add this code:

script type=“text/javascript”>
var _qevents = _qevents || ;

(function() {
var elem = document.createElement(‘script’);
elem.src = (document.location.protocol == “https:” ? “https://secure” : “http://edge”) + “.quantserve.com/quant.js”;
elem.async = true;
elem.type = “text/javascript”;
var scpt = document.getElementsByTagName(‘script’)[0];
scpt.parentNode.insertBefore(elem, scpt);
})();

_qevents.push({
qacct:“p-7P6UE-fZG7uGe”
});
/script>

noscript>
div style=“display:none;”>
img src=“//pixel.quantserve.com/pixel/p-7P6UE-fZG7uGe.gif” border=“0” height=“1” width=“1” alt=“Quantcast”/>
/div>
/noscript>
!-- End Quantcast tag →

However it’s saying the div style="display… is unexpected and is ignoring and similarly for the /noscript>.

This code was auto-generated by an advertising company and can’t be changed. Anything I can do to make it recognize it?

( I’ve removed many “<” start brackets to make the forum notice the code, wasn’t showing otherwise.

Hi @ocadhla, thanks for your post. Our custom code editor does not support the noscript tag, so you need to wrap that code in a javascript writeln function, which will write out the correct code to the page at run-time.

The code should look like below until you get to the noscript tag:

<script type="text/javascript">
var _qevents = _qevents || [];

(function() {
var elem = document.createElement('script');
elem.src = (document.location.protocol == "https:" ? "https://secure" : "http://edge") + ".quantserve.com/quant.js";
elem.async = true;
elem.type = "text/javascript";
var scpt = document.getElementsByTagName('script')[0];
scpt.parentNode.insertBefore(elem, scpt);
})();

_qevents.push({
qacct:"p-7P6UE-fZG7uGe"
});
</script>

Where you have the noscript tag, you should replace with:

<script language="JavaScript">
<!--
document.writeln("<noscript>");
document.writeln("<div style=\"display:none;\">");
document.writeln("<img src=\"//pixel.quantserve.com/pixel/p-7P6UE-fZG7uGe.gif\" border=\"0\" height=\"1\" width=\"1\" alt=\"Quantcast\"/>");
document.writeln("</div>");
document.writeln("</noscript>");
//-->
</script>

When you paste code in the forum, after you paste it, use the code button in the toolbar to format your code for the post.

Try that code, and see if it helps. If you save the code and publish, but it is not working, then can you also share the published site link, so that we may look if there is any browser console errors.

​I hope this helps. If not, please let me know – I’m happy to assist further! :slight_smile:

Cheers,
Dave

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.