Tagged: x
-
AuthorPosts
-
November 14, 2016 at 9:24 pm #1257406
JoAnn FParticipantI have added a custom script to two of my pages and it works fine using the code below. My issue is that I need it to load immediately after the opening head tag before the analytics code. Is there anyway to do this?
Thank you for your help.
This is the code I added to my child theme functions.php file:
function script_for_spec_page() {
if ( in_array( get_the_ID(), array( 2297, 2786 ) ) ) { ?>
<!–Add Your Javascript Below this line–><!– Google Analytics Content Experiment code –>
<script>function utmx_section(){}function utmx(){}(function(){var
k=’77520528-0′,d=document,l=d.location,c=d.cookie;
if(l.search.indexOf(‘utm_expid=’+k)>0)return;
function f(n){if(c){var i=c.indexOf(n+’=’);if(i>-1){var j=c.
indexOf(‘;’,i);return escape(c.substring(i+n.length+1,j<0?c.
length:j))}}}var x=f(‘__utmx’),xx=f(‘__utmxx’),h=l.hash;d.write(
‘<sc’+’ript src=”‘+’http’+(l.protocol==’https:’?’s://ssl’:
‘://www’)+’.google-analytics.com/ga_exp.js?’+’utmxkey=’+k+
‘&utmx=’+(x?x:”)+’&utmxx=’+(xx?xx:”)+’&utmxtime=’+new Date().
valueOf()+(h?’&utmxhash=’+escape(h.substr(1)):”)+
‘” type=”text/javascript” charset=”utf-8″><\/sc’+’ript>’)})();
</script><script>utmx(‘url’,’A/B’);</script>
<!– End of Google Analytics Content Experiment code –><!–Do not modify anything below this line–>
<?php
}
}
add_action(‘wp_head’,’script_for_spec_page’);November 15, 2016 at 1:20 am #1257567
RupokMemberHi there,
Thanks for writing in! You can try setting a higher priority :
add_action('wp_head','script_for_spec_page', 9999);Hope this helps.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1257406 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
