Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to edit Header in order to delete Google Analytics code duplicate
Tagged: edit header, google analytics code
- This topic has 8 replies, 2 voices, and was last updated 6 years, 7 months ago by holybuble.
-
AuthorPosts
-
August 25, 2017 at 3:41 pm #210766holybubleMember
I'm worried I have a duplicate GU code and I need to have access to the full header.php code in order to check if that is the case.
Plus, I need to add this string of code
<?php if (!is_user_logged_in()) { ?>
INSERISCI QUI IL TUO CODICE DI MONITORAGGIO
<?php endif; ?>in order to prevent analytics to track my wordpress backend vists (previews, etc.).
Can you guys help me?
https://www.scrivente.it
I'm not expert whatsoever, but I went to editor and I'm pretty sure header.php code is cut short.August 25, 2017 at 3:59 pm #210767Victor FontModeratorYou have Google Analytics code only once. There is no header source code as you may think. Header scripts are added through plugins, in the Genesis/Theme Settings page header scripts area, or through Genesis Simple Hooks plugin. Header code is generated on the fly through the Genesis Framework.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?August 25, 2017 at 4:48 pm #210770holybubleMemberHello Victor, thank you very much.
What about how to add the following string of code...How can I do that?
<?php if (!is_user_logged_in()) { ?>
ANALYTICS CODE
<?php endif; ?>August 26, 2017 at 5:52 am #210784Victor FontModeratorPHP is best added to the header with the Genesis Simple Hooks plugin as I mentioned above.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?August 26, 2017 at 6:44 am #210786holybubleMemberVictor, I can't thank you enough for your prompt replies.
However, with Simple Hooks, there's no way to edit the Google Analytics in order put the script I mentioned before and after it.August 26, 2017 at 10:23 am #210789Victor FontModeratorYou never asked about editing Google analytics code or putting a script before or after the analytics code. You asked how to insert a script. What exactly are your trying to do? Be specific. If you are asking how to add the php conditional around the existing analytics code, then you have to explain how you are adding the analytics code in the first place. It's not possible to know from viewing your site or with any of the explanation you've provided so far.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?August 26, 2017 at 10:33 am #210791holybubleMemberHello Victor, I'm asking you how to add the php conditional around the existing analytics code.
I have add the analytics code via Optmize Press.
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');ga('create', 'UA-91737299-1', 'auto');
ga('send', 'pageview');</script>
August 27, 2017 at 1:15 am #210799Victor FontModeratorSince you added the analytics script through Optimize Press, you are working outside of anything the Genesis framework can control. Because of this choice, you cannot use Genesis to accomplish what you want. You are left with two choices. You can open a support ticket with the Optimize Press developers and ask if there's a way to conditionally display the Google Analytics code. Perhaps they have a filter that can be used to conditionally output the script.
Your second choice is to not use Optimize Press to output the analytics script and move your script with conditional wrap to Genesis Simple Hooks.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?August 27, 2017 at 1:44 am #210804holybubleMemberI got you.
Thank you Victor.
I'll try open a ticket with Optmize Press, then. -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.