Wat's the easiest way to add code snippet on my website?

Joalis

Regular Member
Joined
Jan 7, 2020
Messages
203
Reaction score
29
Hello,

I want to start using Yandex Metrics on my website. In order to do it I have to Install the code snippet on the site, but I do not have any experience with coding.

Maybe there any other, simpler way to do it?
 
Hello,

I want to start using Yandex Metrics on my website. In order to do it I have to Install the code snippet on the site, but I do not have any experience with coding.

Maybe there any other, simpler way to do it?
It depends. How did you create your website? Did you use any CMS like Wordpress or something similar?
 
Ups, forgot to mention. Wordpress
Locate wp-content/themes/yourthemename/header.php and add it just before head ends. Should do the job.
If you are using a third party theme, create a child theme -> copy header.php to the child theme, and do the same as above; but in the child theme's header.php.
 
Ups, forgot to mention. Wordpress
Then use theme options and paste your code in the header / footer box.

Also, If you are using any plugins like Yoast,All in one SEO,then there is a option to paste site level codes. Make a use of those fields.
 
Locate wp-content/themes/yourthemename/header.php and add it just before head ends. Should do the job.
If you are using a third party theme, create a child theme -> copy header.php to the child theme, and do the same as above; but in the child theme's header.php.
Thanks for so detailed answer. Just want to doublecheck.

I have to paste my code right here?

v39bvlV
 
Thanks for so detailed answer. Just want to doublecheck.

I have to paste my code right here?

v39bvlV
Nopes not there, you can paste it in line 16, or just before you see </head>, or press enter after line 29, and paste it there.
 
Nopes not there, you can paste it in line 16, or just before you see </head>, or press enter after line 29, and paste it there.
Do you mean in line 15? Because line 16 is after </head>
 
Out of curiosity, why do you all suggest adding code in header instead of footer?
 
Do you mean in line 15? Because line 16 is after </head>
That's the start of head.. It is <head> tag. The end is </head>.
It's pretty simple if you think about it just a little. Works pretty much like xml.
Out of curiosity, why do you all suggest adding code in header instead of footer?
Atleast with GTM, adding it in the header helps detecting some issues like bounce. If the user opened the page, but exited before the page could load (generally happens because of slow connection, or other render blocking script).. it will catch that. In </body>, it might not. ;)

P.s., not to mention, other scripts except for analytics/metrics etc should always be loaded before </body>
 
Last edited:
Atleast with GTM, adding it in the header helps detecting some issues like bounce. If the user opened the page, but exited before the page could load (generally happens because of slow connection, or other render blocking script).. it will catch that. In </body>, it might not. ;)
I guess that makes sense, but as a general rule I prefer to load the content first. Otherwise the visitor gets a lot of dead time waiting to load every script.

P.s., not to mention, other scripts except for analytics/metrics etc should always be loaded before </body>

Yes, that's what I said as well. Add code above the </body> tag.
 
Best to not mess up with Codes and put google tag manager ID in the plugin.
Then any new tracking pixel you want to add on website add in Tag manager only. No need to add on website.
This is best practice to add multiple tracking codes in website without interfering with codes.
 
Nopes not there, you can paste it in line 16, or just before you see </head>, or press enter after line 29, and paste it there.
I installed my code after line 29, but it still not working

zLMDeAc


maybe do you know what could be a problem?
 
I installed my code after line 29, but it still not working

zLMDeAc


maybe do you know what could be a problem?
Caching probably? Try clearing it (including any dns caching you might have through cloudflare). Also look in the source code if that code exists (ctrl + u) in your site html. If it does, then you are probably not being detected as an user because of dnt request/ ad blocker.
 
Last edited:
Yup it will also work there. Some bounces might not be detected, but it will work for sure.

Caching probably? Try clearing it (including any dns caching you might have through cloudflare). Also look in the source code if that code exists (ctrl + u) in your site html. If it does, then you are probably not being detected as an user because of dnt request/ ad blocker.
Yup, cleared cache helped. Thanks a lot!
 
Back
Top