add code to the child theme functions.php file
-
Hello , I want to add this function to the functions.php file of my theme son, I have to
modify the code ?disqus_config function () {
this.callbacks.onNewComment = [function () {_ga.push([‘_trackevent’,’formulario’,’enviado’,<? php the_title();?>’]);/>
}
-
To add this code to functions.php go to:
Appearance->Editor
Click Theme Functions”functions.php” on right-hand side.
Scroll to after the part that says “This is where Customizr begins” to blank space and paste this code.
If you get a white screen download WinSCP and contact your hosting provider and they will help you get back onto your site.
Hi @leblanc1, this javascript code will generate error if you paste it like as it is currently written in functions.php.
You’ll want to wrap it into php tags and hook it in wp_head or wp_footer for example.
I hope this helps!nikeo hi , thanks for answering . I need your help, if I need to wrap this code in wp_footer to add it to my theme functions file customizr son , would I like would you say to add correctly? . What I want to do is measure the comments of my blog with google analytics and I installed on the blog for comments Disqus .
How does this code would be nice to add to the file are listed functions.ph my son customiz topic ?. Thanks in advancefunction disqus_config( ) {
this.callbacks.onNewComment= {function( ) else{ _gash.push([‘_trackevent’, ‘comment’, ‘send’, ‘<php the title( )?>’])};
}leblanc1 that is a javascript code. Where did you take that code? I don’t think is correct…
hello d4z_c0nf. I’m not a programmer, and I want advice from a programmer to help me, I have taken an example of disqus which is a plugin for comments. I want to measure my blog’s comments with events in google analytics and I have to install a code to add the function to the functions.php file of my theme son customizr. I need help with code
leblanc1 I would like to help you, I can tell you how to put javascript code in wp_footer, in wp_header, but are you sure that code will work? For example this
<php the title( )?>is wrong and should be:<?php the_title(); ?>also a function which starts withelsedoesn’t convince me, but maybe I’m wrong on this point..
Basically this is the code to add javascript in wp_footeradd_action('wp_footer','disqus_track', 10); function disqus_track() { ?> <script type="text/javascript"> /* script here */ function disqus_config() { this.callbacks.onNewComment = [ function() { _gash.push(['_trackevent', 'comment', 'send', '<?php the_title(); ?>'])} ]; } </script> <?php }While I was writing this I’ve found this
And the javascript it uses is the correct one… so I changed it in your code.
Hope this helps
Thank you so much for helping me d4z_c0nf, ¿/ * script here * / I leave alone ?. Now , I add the code you have given me , once inserted , I have to wait to see the results in google analytics , a million thanks d4z_c0nf
Hopefully it will work 😀
And yes you can remove that /* script here */
sorry for that useless comment 😀as soon as you notice, and many thanks for helping me work with code. regards
Np,
if it will work will you come back to mark this topic as resolved? 😀If apologize , I forgot to tick the issue resolved , now the frame. and a million thanks for helping
You’re welcome 😉
hi d4, does not work, google analytics does not measure me disqus comments
Hi leblanc1,
I’m sorry. The thing is that’s the way to add javascript in the footer in wordpress. Now why it doesn’t work? Probably ’cause that script isn’t correct for your needs, dunno..hello 4z,I think the problem is trackEvent , category , tag action and event , I think not accepted as the_title label , what you give as a category, share and tag ?
The topic ‘add code to the child theme functions.php file’ is closed to new replies.
