Tagged: x
-
AuthorPosts
-
July 22, 2016 at 5:18 am #1098426
ealorParticipanthi !
Filtering IP with google analytics is not a good issue for me, and I want exclude connected users from data sent to GA.My GA ID is set with the GA plugin you provide, works in the header (best practice), nice it works 😉 BUT how exclude connected users ?
I found a php that seem to be efficient :
<?php if(!current_user_can(‘manage_options’)){ ?>
<script type=”text/javascript”>
[here put the script Google Analytics]
</script>
<?php } ?>BUT where put this (if it works) to keep GA working in all headers ?
And it shoud be more suitable for anyone to add a check box in your plugin “exclude connected users” than add functions in child theme and so on…! no ?
than you for your attention
cordiallyJuly 22, 2016 at 6:57 am #1098509
LelyModeratorHi There,
Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.
Then add the code on your child theme’s functions.php file like this:
function third_party_tracking_code() { if(!current_user_can('manage_options')){ ?> <script type="text/javascript"> [here put the script Google Analytics] </script> <?php }} add_action( 'wp_head', 'third_party_tracking_code' );This link might help:https://community.theme.co/kb/customization/actions-and-filters-in-x/
We certainly appreciate the feedback! This is something we can add to our list of feature requests. This way it can be taken into consideration for future development. All of these items are discussed with our team internally and prioritized based on the amount of interest a particular feature might receive. Thanks!
July 25, 2016 at 4:05 am #1101553
ealorParticipantthanks, done ==> waiting now a day or two to check if it works clean / I’ll keep you in touch
July 25, 2016 at 4:58 am #1101606
ChristianModeratorYou’re welcome.
July 25, 2016 at 5:03 am #1101608
ealorParticipantI have an error ==> site down for maintenance… So I go back previous function.php.
May be syntax error ? is really <script type=”text/javascript”> necessary instead of <script> ?Down here is the function.php that shoud work (but not), notice that I added loading a google font previously :
<?php
// =============================================================================
// FUNCTIONS.PHP
// —————————————————————————–
// Overwrite or add your own custom functions to X in this file.
// =============================================================================// =============================================================================
// TABLE OF CONTENTS
// —————————————————————————–
// 01. Enqueue Parent Stylesheet
// 02. Additional Functions
// =============================================================================// Enqueue Parent Stylesheet
// =============================================================================add_filter( ‘x_enqueue_parent_stylesheet’, ‘__return_true’ );
// Additional Functions
// =============================================================================function my_custom_head_output() {
?>
<link href=’https://fonts.googleapis.com/css?family=Homemade+Apple’ rel=’stylesheet’ type=’text/css’>
<?php
}add_action( ‘wp_head’, ‘my_custom_head_output’, 99999 );
function third_party_tracking_code() {
if(!current_user_can(‘manage_options’)){
?>
<script type=”text/javascript”>
(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-xxxxxxx’, ‘auto’);
ga(‘send’, ‘pageview’);
</script><?php }}
add_action( ‘wp_head’, ‘third_party_tracking_code’ );
any idea ?
thanksJuly 25, 2016 at 7:12 am #1101713
Paul RModeratorHi,
Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / password
– FTP credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
July 25, 2016 at 7:57 am #1101771
ealorParticipantThis reply has been marked as private.July 25, 2016 at 7:58 am #1101774
ealorParticipantThis reply has been marked as private.July 25, 2016 at 11:19 am #1102085
DarshanaModeratorHi there,
Thanks for the FTP information provided. I went ahead and updated your code in your child theme’s functions.php file.
Please make sure to update your code with the your Google Analytics ID.
Replace the following in the code with your actual Google Analytics ID
UA-xxxxxxxLet us know how it goes.
Thanks!July 27, 2016 at 5:05 am #1104871
ealorParticipantSeem it works, thanks ! I look tomorrow to see if GA will works great also and exclude connected users as wanted… and tell you.
can you say me what you corrected on the code provided ? Or what mistake I done ?
thanks
July 27, 2016 at 8:08 am #1105080
JoaoModeratorHi There,
Your google ID was added to the code.
“Replace the following in the code with your actual Google Analytics ID
UA-xxxxxxx”Hope that helps
Joao
July 28, 2016 at 3:51 am #1106763
ealorParticipanthi great supp 😉
of course I set correct UA ID…
website works great with function.php edited in child theme, but exclude connected users seems to be inefficient !
I look to real time traffic in google analytics: not connected I can see my hits, connected I can also see my hits / seems filter doesn works… bad thing
any idea ? (I use php 7)
thank you
July 28, 2016 at 4:47 am #1106841
Rue NelModeratorHello There,
For more better control of your Google Analytics, please use a 3rd party plugin instead. Perhaps this one could help:
MonsterInsights – Google Analytics Dashboard for WordPress (Website Stats Made Easy)
Hope this helps. Please let us know how it goes.
July 29, 2016 at 4:41 am #1108571
ealorParticipantseems it works great now! thank you.
have a nice week-end
July 29, 2016 at 5:23 am #1108617
LelyModeratorYou’re welcome!
Cheers!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1098426 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
