Tagged: x
-
AuthorPosts
-
March 23, 2017 at 8:17 am #1417594
Hi guys,
I need to add the following code to a site on all pages. I tried the scripts n styles plug-in which had worked for me on another site, but it hasn’t taken for some reason.
It needs to be in the Body element of every page.
Do you have any suggestions, would be greatly appreciated!
<!-- Quantcast 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-Jw6cuZBU3Y0qw" }); </script> <noscript> <div style="display:none;"> <img src="//pixel.quantserve.com/pixel/p-Jw6cuZBU3Y0qw.gif" border="0" height="1" width="1" alt="Quantcast"/> </div> </noscript> <!-- End Quantcast tag -->
March 23, 2017 at 8:30 am #1417606This reply has been marked as private.March 23, 2017 at 10:44 am #1417811Hey Steve,
X has an action hook below the opening <body> tag (
x_before_site_begin
) so you could tap into it to add your script likeadd_action( 'x_before_site_begin', 'my_script' ); function my_script() { ?> <!-- Quantcast 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-Jw6cuZBU3Y0qw" }); </script> <noscript> <div style="display:none;"> <img src="//pixel.quantserve.com/pixel/p-Jw6cuZBU3Y0qw.gif" border="0" height="1" width="1" alt="Quantcast"/> </div> </noscript> <!-- End Quantcast tag --> <?php }
The code should be added in your functions.php. Please notice the PHP tags because depending on your setup, you might need to close the PHP tag or else, you’ll get a fatal error.
Thanks.
March 28, 2017 at 6:46 am #1422874Implemented without blowing up the site, so far so good!
I’ll let you know if it’s all working ok, but looks like it will all be good…
Many thanks chaps!
March 28, 2017 at 12:28 pm #1423214You are most welcome. 🙂
-
AuthorPosts