Blog

Home > Blog > Exclude All Wordpress Internal Traffic from Google Universal Analytics

Exclude All Wordpress Internal Traffic from Google Universal Analytics

We have been able to exclude GA code from running for logged in users. But what if we also want to exclude the future sessions of the internal users when they visit as logged out users? This is helpful because wordpress frequently logs out users and our main objective is to filter out internal users from our GA traffic regardless of whether they are logged in or not.

This can be done by setting a user scope custom dimension on the user. This would then exclude all future sessions of the particular user from GA.

Create Custom Dimension

Login to Google Analytics > Select your profile > Go to Admin > In the property row select Custom Definitions > Custom Dimensions > Click New Custom Dimension

On the next page click Add a name (I used User Type) > Set scope to User > Hit Create > then Done

On the screen now note the Index of your newly created custom dimension. Got it? Next Within your wordpress template add this to footer.php

<?php if ($user_ID) : ?>
<script>
// enter index below
var dimIndex = 1;
 
// set custom dimension
ga('set', 'dimension'+dimIndex, 'Registered User');
// send data to GA
ga('send', 'event', 'User Type', 'Registered User', {'nonInteraction': 1});
</script>
<?php endif; ?>

On the line var dimIndex = 1; change the number to the Index of custom dimension you created.

Filter Users With Custom Dimension Value

Finally create a filter in your google analytics view to exclude Users who have this custom dimension value.

Going forward any user who has logged in to the site once will be excluded from your Analytics view. This can be used in conjunction with IP exclude filters to make sure any internal users are excluded.

 Filter Custom Dimension

Filter Custom Dimension

ps. this will exclude any users that have logged in once. So if you are a membership site or a wordpress site which creates accounts for external users this method should not be used.

Share:

Data that Moves Your Business

Connect with Marketlytics

Join 120,000+ Marketers

Stay ahead with expert insights on marketing analysis, data-driven strategies, and industry trends.

Omair

Revenue Growth Analyst
Data Unification Specialist, previously at a leading Ecommerce Giant

Case Studies

Discover our latest success stories
and see how innovative strategies
drive measurable results.

Get a Free Attribution Dashboard

Gain clear insights into what’s
driving conversions and optimize
your marketing spend with ease.

Are you Ready to Fast Track your Marketing Attribution Decisions and Maximize your ROI?

Businesses that leverage automated marketing
attribution see a 20-30% improvement in ad
spend efficiency.