Tagged: x
-
AuthorPosts
-
April 15, 2016 at 2:33 pm #884736
WebHorse413ParticipantI am unable to edit the header.php file for any of my sites using the x theme. I have created a child theme and copied the header.php files from the parent via FTP, but they do not include the <HEAD> </HEAD> and I have no way of including the tracking. please help.
April 16, 2016 at 4:39 am #885520
ThaiModeratorHi There,
To add the google analytics tracking code, please add the following code under functions.php file locates in your child theme:
add_action( 'wp_head', 'x_google_code' ); function x_google_code(){ ?> <!-- Your Google Analytics Code Go Here --> <?php }Hope it helps 🙂
April 18, 2016 at 2:42 pm #888838
WebHorse413ParticipantExcellent I will do this right now. Just to be certain, I would be adding my code in between both “–” and replacing the “Your Google Analytics Code Go Here” with the tracking code, but leaving everything else as is?
April 18, 2016 at 3:01 pm #888877
WebHorse413ParticipantAnd this is the tracking code I usually use. Do I use this format or just the tracking ID when adding the code this way?
<script>
(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.instBefore(a,m)
})(window,document,’script’,’https://www.google-analytics.com/analytics.js’,’ga’);ga(‘create’, ‘UA-69475208-2’, ‘auto’);
ga(‘send’, ‘pageview’);</script>
April 18, 2016 at 3:40 pm #888922
marketing@transloc.comParticipantHey there support,
I just happened upon this post and it got me thinking. Is it okay for me to have the google analyics code in global custom JS section in the customizer? Or should I also place the code in functions.php file?
Thanks!
April 19, 2016 at 2:45 am #889470
ChristopherModeratorHi there,
@webhorse413
Please add your code just after following line :<!-- Your Google Analytics Code Go Here -->Analytics code should be added to functions.php file or it should be added via ‘Google Analytics’ plugin.
Hope it helps.
April 19, 2016 at 9:51 am #890167
marketing@transloc.comParticipantThanks. I have other tracking code also, what’s the best way to include those on our website?
April 19, 2016 at 4:01 pm #890787
JadeModeratorHi there,
just add this in your child theme functions.php file
add_action( 'wp_head', 'x_google_code' ); function x_google_code() { if ( is_page(8) ) { ?> <!--Add Your Javascript Below this line for page 8 --> <!--Do not modify anything below this line--> <?php } if ( is_page(9) ) { ?> <!--Add Your Javascript Below this line for page 9 --> <!--Do not modify anything below this line--> <?php } }Replace the #8 and #9 to the page ID of the page you only want to add the script to.
Guide on how to get post/page ID -> http://theme.co/x/member/kb/how-to-locate-post-ids/
Hope that helps.
April 21, 2016 at 10:18 am #893813
WebHorse413ParticipantHello, I did as you said but when I scanned my site it came back as having no Google Analytics. My code looks as follows at the very end of my funtions.php file:
});
add_action( ‘wp_head’, ‘x_google_code’ );
function x_google_code(){
?>
<!– Your Google Analytics Code Go Here –>
<script>
(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’https://www.google-analytics.com/analytics.js’,’ga’);ga(‘create’, ‘UA-69475208-2’, ‘auto’);
ga(‘send’, ‘pageview’);</script>
<?php
}Is this correct?
April 22, 2016 at 12:07 am #894776
RupokMemberHi @webhorse413
Your code seems correct and should be added on the page. Kindly check the source code. You could also provide us the URL so that we could check too.
Cheers!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-884736 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
