Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?
Closed 6 years ago.
Improve this questionim facing this kind of issue, ie, Unable to paste google analytics on header.php. Error showing : Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over FTP. So, even i tried over ftp. Kindly help . Also unable to edit functions.php file too. Thanks in advance.
Closed. This question is off-topic. It is not currently accepting answers.Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?
Closed 6 years ago.
Improve this questionim facing this kind of issue, ie, Unable to paste google analytics on header.php. Error showing : Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over FTP. So, even i tried over ftp. Kindly help . Also unable to edit functions.php file too. Thanks in advance.
You can use this Plugin and it will automatically insert the code for you on every page.
Just download the plugin and add your code to the header box that the pugin provides. Super easy to use and super lightweight.
Plugin: Insert Headers and Footers
https://pt.wordpress/plugins/insert-headers-and-footers/
That's perfectly normal, it's a security feature.
My advice is that you do it via FTP and add the code to your footer file (usually footer.php) before the closing tag.
Ideally, you want to be using a child-theme.
You should be using the wp_head
filter to add things to the or footer area. Similar to this:
add_action('wp_head', 'my_analytics');
function my_analytics() {
?>
<!-- put your analytics script code here -->
<?php
return;
}
This code is placed in your Child Theme's functions.php . (You always want to use a Child Theme, so any changes you make are not killed by a theme update. You never want to modify theme code directly.)
But, be aware that client-side analytics will be blocked by many ad-blockers, so you may not get full 'participation' in your analytics.
Best to implement a server-side analytics process. Many googles on how to do that.
Alternately, there are many plugins that will properly insert your analytics code in your site.