Putting Goggle Analytics Code in X theme?

Hi I wanna put Goggle Analytics Code in my X theme.

People say to edit header.php file of the theme and put the code there.

Is there any another simple method to add the code?

Hey Sansar,

Yes. X includes the Google Analytics plugin so you just have to install it from the X Dashboard then add the Analytics ID in the plugin’s settings:

Hope this helps.

hi Thanks for your reply

I avoid plugins because plugins are heavy and make pages load low. is there any other way so i can manually add code somewhere?

Hey Sansar,

Yes, you can also add the analytics code through the child theme. Please install and activate the child theme and login through FTP then edit the functions.php then add this code:


add_action('wp_head', 'add_header_code');
function add_header_code(){
?>
    <!-- Analytics code -->
<?php
};

Then you may remove <!-- Analytics code --> and place the analytics code there.

Hope this helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.