-
AuthorPosts
-
February 10, 2015 at 2:09 pm #203427
I have just found a tool for monitoring your site, recording user interaction and metrics, chat etc… I found it very useful for me. The site has to include a JavaScript on all pages so they can be tracked. They generate a code that needs to be embedded on the pages.
I have used the Customiser and Custom JavaScript area. Some how X Theme do something with the code that makes is not effective on the pages.
After chatting with the LuckyOrange developer he took a look on the code and provided me with a modified version that can be used in the Custom Javascript in the X Theme customiser.
So if anybody else is facing this issue, here is the code that works: ( Just replace the 99999 with you real Site ID )
window.__wtw_lucky_site_id = 99999;
(function() {
var wa = document.createElement(‘script’); wa.type = ‘text/javascript’; wa.async = true;
wa.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://cdn’) + ‘.luckyorange.com/w.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(wa, s);
})();Regards,
Paulo Tebet
February 10, 2015 at 10:57 pm #203719Hi there,
Thank you for sharing your solution.
It’s better to setup a child theme when you’re adding similar JavaScript. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.
Create a JavaScript file for your custom JS code and then follow the code below, add it into your Child Theme’s functions.php file.
function custom_external_js() { wp_enqueue_script('your-own-js', get_stylesheet_directory_uri() . '/custom_external.js', array('jquery')); } add_action('wp_enqueue_scripts', 'add_my_script');
make sure to replace this
/custom_external.js
with the correct path/file-name.Hope that’s clear.
February 14, 2015 at 3:27 pm #206723Thanks for the instructions.
I am using a child theme, but was just pasting the regular JavaScript on the Custom Java Script on the Customiser.
I will try your suggested way to be able to use the regular script.
Regards,
Paulo Tebet
February 15, 2015 at 6:04 pm #207208Okay cool, let us know how it goes 😉
-
AuthorPosts