Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #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

    #970656

    Hey 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,
    Dude

    #970790

    Hey 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

    #970988

    Hi 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,
    Rikard

    #971390

    Hi 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

    #971870

    Hi 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,
    Victoria

    #971873

    Hi 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

    #972127

    Hi 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,
    Rikard

    #972519

    Hi Rikard!

    Thank you!!

    Warmly,

    Havi

    #972860

    Hi 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,
    Rikard

    #972916

    Thank you, Rikard!! :)

    You guys are always there for me (and everybody) :)

    Yes, you can close this ticket. I’m all set!!

    Warmly,

    Havi

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Cannot Verify Property on Webmasters’ is closed to new replies.