-
AuthorPosts
-
June 10, 2018 at 3:16 am #970592
Need to add GA in side of <head></head>
I found these instructions. Would this work? Does it have to be the first add_action or can I add it at the end ?
Add to functions.php on child theme:
add_action(‘wp_head’, ‘wpb_add_googleanalytics’);
function wpb_add_googleanalytics() { ?>
// Paste my Google Analytics code from here
<?php }(Opening and closing tags are already on the php file or do I have to add them again?)
Thank you!!
Havi
June 10, 2018 at 8:02 am #970656Hey havi,
No this will not work. The easiest solution is probably to install a plugin like https://wordpress.org/plugins/webmaster-tools-verification/ and to follow the instructions. After verification you can remove he plugin to avoid performance problems.
Best regards,
DudeJune 10, 2018 at 4:20 pm #970790Hey Dude,
No. That will not work. You cannot verify and remove the method of verification (and I do not want to add a plugin) as the property will unverify itself (this is what happened) Google webmaster keeps on checking t make sure you have rights to the data.
Also, the implementation of Google Analytics tags should be inside of the head Not on the footer.
I found several tickets of solutions you were providing to people. Mine was a compilations of many of them and I wanted to run it by you before implementing as code has changed so much.
This was Victoria’s solution: https://kriesi.at/support/topic/google-analytics-tracking-code-not-in-head/
Here is yours (but Ismael said it doesn’t work an it was back in 2014) https://kriesi.at/support/topic/google-analytics-code-2/
Could you please, provide me with a way to add the Google Analytics code on the Head?
Thanks you!
Havi
June 11, 2018 at 8:43 am #970988Hi Havi,
There are several ways of verifying properties in Google WMT, I usually upload a simple html file provided by Google. Maybe you could try that instead?
Best regards,
RikardJune 11, 2018 at 9:04 pm #971390Hi Rikard,
Unfortunately I was unable to have it verified in any other way as there was some kind of DNS issue and Google was getting an HTTP 500. I would still like to have GA code implemented properly inside of the <head>
I was able to have it verified and the DNS problem showed up on Search Console. I couldn’t see what was happening until I was able to verify.
Why wouldn’t that solution work? I don’t want the sites to become unverified by Search Console. They default to the recommended method not the alternative ones.
Thank you!
Havi
June 12, 2018 at 9:30 pm #971870Hi Havi,
Can you please share the code that you need to be added to get verified?
Can you please check server log for error?
Best regards,
VictoriaJune 12, 2018 at 9:33 pm #971873Hi Victoria!
I was already able to verify. There was a DNS error (trying to figure out if it was Cloudflare) but only to Googlebot. Super strange.
I would still like to know if the solution you shared is something I could implement so I can add the GA code to the <head> If not, I may have to go the GTM route. (I’ve done that one) ;)
Thank you!!
Havi
June 13, 2018 at 9:14 am #972127Hi Havi,
Great, glad you got it working. The function you posted initially should work in normal cases I think. If you only need the script in the header then you could also try to paste it in the Google Analytics box.
Best regards,
RikardJune 13, 2018 at 10:30 pm #972519Hi Rikard!
Thank you!!
Warmly,
Havi
June 14, 2018 at 4:05 pm #972860Hi Havi,
Glad we could help :-)
Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
RikardJune 14, 2018 at 5:06 pm #972916Thank you, Rikard!! :)
You guys are always there for me (and everybody) :)
Yes, you can close this ticket. I’m all set!!
Warmly,
Havi
-
AuthorPosts
- The topic ‘Cannot Verify Property on Webmasters’ is closed to new replies.