{"id":17830,"date":"2023-05-12T19:17:15","date_gmt":"2023-05-12T19:17:15","guid":{"rendered":"https:\/\/www.searchenginejournal.com\/how-to-filter-internal-traffic-in-google-analytics\/485913\/"},"modified":"2023-05-12T19:17:15","modified_gmt":"2023-05-12T19:17:15","slug":"how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev","status":"publish","type":"post","link":"https:\/\/marketingnewsbox.com\/?p=17830","title":{"rendered":"How To Exclude Internal Traffic In Google Analytics 4 via @sejournal, @vahandev"},"content":{"rendered":"<p><a href=\"https:\/\/www.searchenginejournal.com\/google-analytics-4-guide\/407452\/\">Google Analytics 4<\/a> (GA4) is rolling out in a rush, and if you\u2019re reading this guide, you might be having a tough time figuring out how it works.<\/p>\n<p>One area that might be causing you confusion is filtering out internal traffic.<\/p>\n<p>If you\u2019re like me, you\u2019re already missing how user-friendly Universal Analytics (UA) was \u2013 especially when it came to filtering out traffic.<\/p>\n<p>In UA, you had full control over how you could filter out traffic.<\/p>\n<p>See the beauty it had.<\/p>\n<div>\n<dl id=\"attachment_485917\">\n<dt>\n<div class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev.png\" alt=\"Universal Analytics Filters UI\" width=\"1268\" height=\"804\" class=\" b-lazy pcimg\"><span class=\"wp-caption-text\">Screenshot from Google UA, May 2023<\/span><img decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev.png\" alt=\"Universal Analytics Filters UI\"><\/div>\n<\/dt>\n<\/dl>\n<\/div>\n<p>Now, I find it hard to understand why GA4 has replaced such a vital function with only an IP-based rule.<\/p>\n<div id=\"gallery-1\" class=\"gallery galleryid-485913 gallery-columns-3 gallery-size-large\">\n<figure class=\"gallery-item\">\n<div class=\"gallery-icon landscape\"> <a href=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" width=\"1426\" height=\"820\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev.jpg\" class=\"attachment-large size-large b-lazy pcimg\" alt=\"IP based filter\" aria-describedby=\"gallery-1-485946\"><img decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev.jpg\" alt=\"IP based filter\"><\/a> <\/div><figcaption class=\"wp-caption-text gallery-caption\" id=\"gallery-1-485946\"> IP based filter <\/figcaption><\/figure>\n<figure class=\"gallery-item\">\n<div class=\"gallery-icon landscape\"> <a href=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-1.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" width=\"1543\" height=\"885\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-1.png\" class=\"attachment-large size-large b-lazy pcimg\" alt=\"Internal Traffic Filter\" aria-describedby=\"gallery-1-485934\"><img decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-1.png\" alt=\"Internal Traffic Filter\"><\/a> <\/div><figcaption class=\"wp-caption-text gallery-caption\" id=\"gallery-1-485934\"> Internal Traffic Filter <\/figcaption><\/figure>\n<\/div>\n<p>The IP-based filter is useless when your company employees are remote as, in most cases, IPs are dynamic, and it is not practical to update the list of IPs daily.<\/p>\n<p>This is why we have created this guide for you to help you filter out undesired traffic \u2013 and, most importantly, internal traffic \u2013 in GA4.<\/p>\n<h2>What Is Internal Traffic?<\/h2>\n<p>\u201cInternal traffic\u201d refers to the web traffic that originates from you and your employees accessing your website.<\/p>\n<p>Your employees\u2019 activity can reduce the quality of your data and make it harder for you to understand what real visitors are doing on the website, and how much traffic you have.<\/p>\n<p>Even though IP-based filters may not be the best way to filter our internal traffic, I would like to start with that method as the easiest path to use \u2013 and as a basis to explain how new data filters work.<\/p>\n<h2>How To Filter Out Traffic Based On IP<\/h2>\n<p>Navigate to <em>Data Streams<\/em> in GA4.<\/p>\n<div>\n<dl id=\"attachment_485940\">\n<dt>\n<div class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-2.png\" alt=\"Data Streams\" width=\"1920\" height=\"820\" class=\" b-lazy pcimg\"><span class=\"wp-caption-text\">Screenshot from GA4, May 2023<\/span><img decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-2.png\" alt=\"Data Streams\"><\/div>\n<\/dt>\n<\/dl>\n<\/div>\n<p>Go to Configure tag settings, click on the <em>Show all<\/em> button, and then click on <em>Define Internal Traffic Rule<\/em>.<\/p>\n<div id=\"gallery-2\" class=\"gallery galleryid-485913 gallery-columns-3 gallery-size-medium\">\n<figure class=\"gallery-item\">\n<div class=\"gallery-icon landscape\"> <a href=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-11.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" width=\"480\" height=\"223\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-1.jpg\" class=\"attachment-medium size-medium b-lazy pcimg\" alt=\"Configure tag settings GA4\" aria-describedby=\"gallery-2-485951\"><img decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-1.jpg\" alt=\"Configure tag settings GA4\"><\/a> <\/div><figcaption class=\"wp-caption-text gallery-caption\" id=\"gallery-2-485951\"> Configure tag settings <\/figcaption><\/figure>\n<figure class=\"gallery-item\">\n<div class=\"gallery-icon landscape\"> <a href=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-16.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" width=\"480\" height=\"223\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-2.jpg\" class=\"attachment-medium size-medium b-lazy pcimg\" alt=\"Define internal traffic GA4\" aria-describedby=\"gallery-2-485949\"><img decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-2.jpg\" alt=\"Define internal traffic GA4\"><\/a> <\/div><figcaption class=\"wp-caption-text gallery-caption\" id=\"gallery-2-485949\"> Define internal traffic <\/figcaption><\/figure>\n<\/div>\n<p>On the popup dialog, click the <em>Create<\/em> button, and you will see a screen where you can enter the IP addresses you want to exclude.<\/p>\n<p>Please note the \u201ctraffic_type=internal\u201d parameter in the dialog.<\/p>\n<p>When you create a rule, whenever it applies, it does append to the Google Analytics hits the parameter \u201ctt=internal\u201d which is saved in the GA4 database.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter b-lazy pcimg\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev.jpg\" alt=\"IP based filter\" width=\"1426\" height=\"820\"><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev.jpg\" alt=\"IP based filter\"><\/p>\n<p>Add data filters by navigating to <em>Data Settings<\/em> then <em>Data Filters<\/em>, and clicking<em> Create Filter<\/em> button.<\/p>\n<div id=\"gallery-3\" class=\"gallery galleryid-485913 gallery-columns-3 gallery-size-thumbnail\">\n<figure class=\"gallery-item\">\n<div class=\"gallery-icon landscape\"> <a href=\"https:\/\/www.searchenginejournal.com\/wp-content\/uploads\/2023\/05\/add-data-filter-ga4-64538cdeb8a90-sej.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"300\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-3.png\" class=\"attachment-thumbnail size-thumbnail b-lazy pcimg\" alt=\"Data filters\" aria-describedby=\"gallery-3-486020\"><img decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-3.png\" alt=\"Data filters\"><\/a> <\/div><figcaption class=\"wp-caption-text gallery-caption\" id=\"gallery-3-486020\"> Data filters <\/figcaption><\/figure>\n<figure class=\"gallery-item\">\n<div class=\"gallery-icon landscape\"> <a href=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-1.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"300\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-4.png\" class=\"attachment-thumbnail size-thumbnail b-lazy pcimg\" alt=\"Internal Traffic Filter\" aria-describedby=\"gallery-3-485934\"><img decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-4.png\" alt=\"Internal Traffic Filter\"><\/a> <\/div><figcaption class=\"wp-caption-text gallery-caption\" id=\"gallery-3-485934\"> Internal Traffic Filter <\/figcaption><\/figure>\n<\/div>\n<p>The basic idea is straightforward: You need to assign a value of your choice to the \u201ctraffic_type\u201d parameter and then use data filters to remove any hits that have that same value assigned to the \u201ctraffic_type\u201d parameter.<\/p>\n<p>There are two options: The \u201cDeveloper\u201d filter and the \u201cInternal Traffic\u201d filter.<\/p>\n<h3>What Is The Internal Traffic Data Filter?<\/h3>\n<p>This filters out any traffic with the traffic_type parameter set to \u201cinternal\u201d by default. The value of the parameter and filter name can be anything.<\/p>\n<h4>How Does The Internal Traffic Data Filter Work?<\/h4>\n<p>For example, you can create an IP filter rule with a parameter traffic_type=europe_headquarters and set a different IP range for your EU office.<\/p>\n<p>You can create as many rules as you want with different traffic_type parameter values, and it will be sent in the hit payload (as tt a parameter) when the visitor IP matches the rule.<\/p>\n<div>\n<dl id=\"attachment_486023\">\n<dt>\n<div class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-5.png\" alt=\"tt parameter in the hit payload\" width=\"1311\" height=\"844\" class=\" b-lazy pcimg\"><span class=\"wp-caption-text\">tt parameter in the hit payload<\/span><img decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-5.png\" alt=\"tt parameter in the hit payload\"><\/div>\n<\/dt>\n<\/dl>\n<\/div>\n<p>Then, by adding a data filter for each IP rule you\u2019ve created, GA4 will exclude hits when traffic_type the data filter setting value matches the tt parameter of the payload&nbsp; \u2013(tt is simply an abbreviation of \u201ctraffic type\u201d).<\/p>\n<h3>What Is The Developer Traffic Data Filter?<\/h3>\n<p>This filter excludes traffic from developers or internal traffic from a company or organization.<\/p>\n<p>Similarly to the internal traffic data filter, it eliminates only data from being recorded in GA\u2019s database, with the difference that you can still see your activity in the <a href=\"https:\/\/support.google.com\/analytics\/answer\/7201382?hl=en\" target=\"_blank\" rel=\"noopener noreferrer\">Debug View<\/a> and its real-time reports.<\/p>\n<p>That is why it is called a developer data filter.<\/p>\n<p>In contrast, you can\u2019t see events from internal traffic in <em>Debug View<\/em> when internal data filters are active.<\/p>\n<h4>How Does The Developer Data Filter Work?<\/h4>\n<p>When debug mode is enabled _dbg payload parameter is included in hits.<\/p>\n<p>Then, the developer data filter eliminates all hits with _dbg the parameter being recorded in the GA4 database.<\/p>\n<p>Debug mode parameter is added when using the preview mode of Google Tag Manager, or when <a href=\"https:\/\/chrome.google.com\/webstore\/detail\/google-analytics-debugger\/jnkmfdileelhofjcijamephohjechhna\" target=\"_blank\" rel=\"noopener noreferrer\">Google Analytics Debugger<\/a> is used.<\/p>\n<div>\n<dl id=\"attachment_486028\">\n<dt>\n<div class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-6.png\" alt=\"_dbg debug view parameter in the payload\" width=\"1285\" height=\"820\" class=\" b-lazy pcimg\"><span class=\"wp-caption-text\">_dbg debug view parameter in the payload<\/span><img decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-6.png\" alt=\"_dbg debug view parameter in the payload\"><\/div>\n<\/dt>\n<\/dl>\n<\/div>\n<h2>Data Filter States<\/h2>\n<p>Data filters have three different states:<\/p>\n<ul>\n<li>Testing.<\/li>\n<li>Active.<\/li>\n<li>Inactive.<\/li>\n<\/ul>\n<p>Active and inactive states are self-explanatory, but you might be wondering what the testing state is.<\/p>\n<p>In the testing mode, you can apply a filter in GA\u2019s reports using the automatically added custom dimension \u201cTest data filter name\u201d equal to your data filter name.<\/p>\n<p>Testing mode is a great feature that allows you to test if your filters work properly before activating them because applying a data filter permanently impacts your data.<\/p>\n<p>It means the data you exclude will not be processed and won\u2019t be accessible in Analytics.<\/p>\n<p>We\u2019ve learned how data filters work by using built-in IP filter rules.<\/p>\n<p>But as I mentioned, this will not work with <a href=\"https:\/\/www.searchenginejournal.com\/build-remote-team-seo-planning\/451303\/\">remote teams<\/a> \u2013 and in that case, it\u2019s better to use a cookie-based approach where you send your team a URL they can open, and their successive visits will be excluded based on the cookies.<\/p>\n<h2><span id=\"databasedfilters\">How To Exclude Traffic In GA4 By Using Cookies<\/span><\/h2>\n<p>I want to be honest at the outset: Setting this up requires many steps.<\/p>\n<p>You need to remember the principle.<\/p>\n<p>We need to send the hits with the traffic_type parameter that we\u2019ve set in data filters when creating them.<\/p>\n<p>This means we will set a cookie on employees\u2019 browsers and check every visit. Whenever that cookie is set, we will set the traffic_type parameter to \u201cinternal.\u201d<\/p>\n<p>Let\u2019s say we are going to use the exclude_user query parameter.<\/p>\n<p>When employees visit the URL \u201chttps:\/\/example.com\/?exclude_user=1\u201d with the query parameter \u201cexclude_user\u201d set to \u201c1\u201d, a sample cookie exclude_user will be set up.<\/p>\n<p>You can send that URL to your employees to use once to open the website and set up cookies.<\/p>\n<p>Please note: Keeping the names of variables the same is important for the codes below to function, and since client-side set cookies expire in seven days in Safari, your employees may need to open that URL once a week \u2013 or you can set cookies when they are logged in to your website server side.<\/p>\n<p>To set up a cookie when one opens the URL https:\/\/example.com\/?exclude_user=1, we need to add a \u201c<a href=\"https:\/\/support.google.com\/tagmanager\/answer\/6107167?hl=en#\" target=\"_blank\" rel=\"noopener noreferrer\">custom HTML<\/a>\u201d tag in GTM with the following script and choose the firing trigger \u201cPageviews All Pages.\u201d<\/p>\n<p>(Hint: You can use <a href=\"https:\/\/www.searchenginejournal.com\/chatgpt-examples\/474937\/\">ChatGPT for coding<\/a>.)<\/p>\n<pre>&lt;script&gt; var urlParams = new URLSearchParams(window.location.search);\n\/\/check if exclude_user query parameter exists and set cookie if (urlParams.has(\"exclude_user\")) { if (urlParams.get(\"exclude_user\") === \"1\") { set_cookie('exclude_user'); } else { delete_cookie('exclude_user'); }\n} function set_cookie(cookie_name) { var date = new Date(); date.setTime(date.getTime() + (2 * 365 * 24 * 60 * 60 * 1000)); var expires = \"expires=\" + date.toUTCString(); document.cookie = cookie_name + \"=1; \" + expires + \"; path=\/\"; } function delete_cookie(cookie_name) { document.cookie = cookie_name + \"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=\/;\"; }\n&lt;\/script&gt;<\/pre>\n<div>\n<dl id=\"attachment_486045\">\n<dt>\n<div class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-7.png\" alt=\"Custom HTML tag in GTM\" width=\"1920\" height=\"820\" class=\" b-lazy pcimg\"><span class=\"wp-caption-text\">Custom HTML tag in GTM<\/span><img decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-7.png\" alt=\"Custom HTML tag in GTM\"><\/div>\n<p>Add the \u201c1st Party Cookie\u201d type of variable with the name \u201cInternal Cookie\u201d and set the cookie name setting as exclude_user.<\/p>\n<\/dt>\n<\/dl>\n<\/div>\n<div>\n<dl id=\"attachment_486047\">\n<dt>\n<div class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-8.png\" alt=\"1st Party Cookie Variable\" width=\"1368\" height=\"399\" class=\" b-lazy pcimg\"><span class=\"wp-caption-text\">1st Party Cookie Variable<\/span><img decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-8.png\" alt=\"1st Party Cookie Variable\"><\/div>\n<p>It will return the value of the exclude_user cookie if it is set, or a special value undefined (not the same as the string \u201cundefined\u201d) if the cookie doesn\u2019t exist.<\/p>\n<\/dt>\n<\/dl>\n<\/div>\n<p>Add a built-in \u201cDebug Mode\u201d variable named \u201cDebug Mode.\u201d<\/p>\n<div>\n<dl id=\"attachment_486056\">\n<dt>\n<div class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-9.png\" alt=\"Debug mode variable\" width=\"1920\" height=\"820\" class=\" b-lazy pcimg\"><span class=\"wp-caption-text\">Debug mode variable<\/span><img decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-9.png\" alt=\"Debug mode variable\"><\/div>\n<\/dt>\n<\/dl>\n<\/div>\n<p>Create a JavaScript type of variable named \u201cInternal Traffic,\u201d copy and paste the code below into it, and save.<\/p>\n<p>This JavaScript variable will return values \u201cinternal\u201d or \u201cdeveloper_view\u201d&nbsp; (could be anything different than \u201cinternal\u201d) to be set up for traffic_type parameter.<\/p>\n<pre>function getTrackingType() { var developer_mode = {{Debug Mode}}; var urlParams = new URLSearchParams(window.location.search); var excludeUserParam = urlParams.get('exclude_user'); \/\/if exclude_user query parameter exists, override the return value. if( excludeUserParam !== null ){ var filter_type_overrdie = (excludeUserParam === null || excludeUserParam === '1'); \/\/if exclude_user paramter is set don't check cookies if( filter_type_overrdie ){ return 'internal'; }else{ return 'developer_view'; } } var internalCookie = {{Internal Cookie}}; if ( internalCookie === \"1\" ) { return 'internal'; } if (developer_mode) { return 'developer_view'; } return undefined;\n}<\/pre>\n<div>\n<dl id=\"attachment_486155\">\n<dt>\n<div class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-10.png\" alt=\"GTM JavaScript variable where we set traffic_type parameter value\" width=\"1920\" height=\"893\" class=\" b-lazy pcimg\"><span class=\"wp-caption-text\">GTM JavaScript variable where we set traffic_type parameter value<\/span><img decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-10.png\" alt=\"GTM JavaScript variable where we set traffic_type parameter value\"><\/div>\n<\/dt>\n<\/dl>\n<\/div>\n<p>It will have a different value than the internal, thus our data filter will not be filtering out our developer views, and we can debug our setup while still having an exclude_user cookie setup.<\/p>\n<p>The purpose of this setup is to exclude developers from website visits when they are not testing while still allowing them to perform debugging when necessary because you need to be able to debug the setup occasionally.<\/p>\n<p>Set the traffic_type parameter to populate from the newly created {{Internal Traffic}} variable in your GA4 configuration tag.<\/p>\n<div>\n<dl id=\"attachment_486066\">\n<dt>\n<div class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-11.png\" alt=\"How to setup traffic_type parameter\" width=\"1555\" height=\"697\" class=\" b-lazy pcimg\"><span class=\"wp-caption-text\">How to setup traffic_type parameter<\/span><img decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-11.png\" alt=\"How to setup traffic_type parameter\"><\/div>\n<\/dt>\n<\/dl>\n<\/div>\n<p>Preview it in <a href=\"https:\/\/www.searchenginejournal.com\/google-tag-manager-ga4-guide\/396169\/\">Google Tag Manager<\/a> (GTM) by opening any URL of your website with the \u201c?exclude_user=1\u201d query string attached, and check that the \u201ctraffic_type\u201d parameter is filled in and that the \u201ctt\u201d hit payload parameter is set to \u201cinternal.\u201d<\/p>\n<p>You can switch between \u201cinternal\u201d and \u201cdeveloper_view\u201d values just by changing the exclude_user query parameter value from 1 to 2.<\/p>\n<p>Once you are sure that the filters work properly and don\u2019t filter out real users\u2019 traffic by mistake, you can activate them from the data filters page, and you are done.<\/p>\n<div>\n<dl id=\"attachment_486208\">\n<dt>\n<div class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-12.png\" alt=\"How to activate data filter in ga4\" width=\"1493\" height=\"708\" class=\" b-lazy pcimg\"><span class=\"wp-caption-text\">How to activate data filter in GA4<\/span><img decoding=\"async\" src=\"https:\/\/marketingnewsbox.com\/wp-content\/uploads\/2023\/05\/how-to-exclude-internal-traffic-in-google-analytics-4-via-sejournal-vahandev-12.png\" alt=\"How to activate data filter in ga4\"><\/div>\n<p>In case you have a gtag.js implementation, you need to add a traffic_type parameter equal to \u201cinternal\u201d to your tag configuration, as shown below.<\/p>\n<\/dt>\n<\/dl>\n<\/div>\n<pre>gtag('set', { 'traffic_type': 'internal' });<\/pre>\n<p>For enabling debug mode, I would suggest using the <a href=\"https:\/\/chrome.google.com\/webstore\/detail\/google-analytics-debugger\/jnkmfdileelhofjcijamephohjechhna?hl=en\" target=\"_blank\" rel=\"noopener noreferrer\">Chrome extension<\/a>.<\/p>\n<p>But I highly recommend using a GTM setup because it is easier to scale, and on big projects, maintenance will be more cost-effective.<\/p>\n<p>If you like coding, at least you can go hybrid by using GTM and pushing data parameters into the data layer on your website\u2019s custom JavaScript.<\/p>\n<h2>Conclusion<\/h2>\n<p>I know what you are thinking after reading this guide.<\/p>\n<p>The path to simplicity is overcomplicated \u2013 and where it once took seconds, you now must spend days setting up your filters properly.<\/p>\n<p>You may not even have the technical knowledge required to implement the steps described in this guide.<\/p>\n<p>However, here is where I would suggest using ChatGPT to get extra help.<\/p>\n<p>If you need a different filter that requires additional custom coding, you can <a href=\"https:\/\/www.searchenginejournal.com\/chatgpt-examples\/474937\/\">ask ChatGPT to code for you<\/a>.<\/p>\n<p>For example, you can ask it to create a JavaScript variable for GTM that returns \u201cinternal\u201d when one visits your website from spammy referrals and excludes spam traffic.<\/p>\n<p>The principle is simple: You should set a traffic_type=\u201dsome_value\u201d parameter to whatever value you want and exclude any hits which have traffic_type parameter set to that value by using data filters.<\/p>\n<p>I hope in the future, the Google Analytics team will add more granular and user friendly control over how you can filter your traffic, similar to Universal Analytics.<\/p>\n<p><strong>More resources:&nbsp;<\/strong><\/p>\n<hr>\n<p><em>Featured Image: Rajat Chamria\/Shutterstock<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google Analytics 4 (GA4) is rolling out in a rush, and if you\u2019re reading this guide, you might be having a tough time figuring out how it works. One area that might be causing you confusion is filtering out internal traffic. If you\u2019re like me, you\u2019re already missing how user-friendly Universal Analytics (UA) was \u2013&#8230; <\/p>\n","protected":false},"author":1,"featured_media":17831,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[103],"tags":[],"class_list":["post-17830","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-search-engine-marketing"],"_links":{"self":[{"href":"https:\/\/marketingnewsbox.com\/index.php?rest_route=\/wp\/v2\/posts\/17830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/marketingnewsbox.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/marketingnewsbox.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/marketingnewsbox.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/marketingnewsbox.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17830"}],"version-history":[{"count":0,"href":"https:\/\/marketingnewsbox.com\/index.php?rest_route=\/wp\/v2\/posts\/17830\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/marketingnewsbox.com\/index.php?rest_route=\/wp\/v2\/posts\/17831"}],"wp:attachment":[{"href":"https:\/\/marketingnewsbox.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/marketingnewsbox.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=17830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/marketingnewsbox.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=17830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}