Back to the Learning Center

By: Casey Grimes on April 25th, 2016

Marketo and Google Analytics Integration Guide: Data Filtering and Sorting

So, in the first and second parts of our series, we covered some of the basics for setting up a properly recording Google Analytics instance. These steps are no doubt important, but for the majority of marketers, this is where their interaction with Google Analytics will end—it’s a nice tool for tracking web activity in aggregate, but not much else.

Read the other five parts in this series to get a cohesive picture of the integration process:

However, much like using Marketo to batch-and-blast your emails, using Google Analytics as a website tracker is like having a sports car and using it only to drive to the grocery store. Google Analytics has a wide variety of features that are often underutilized. Used in conjunction with your marketing automation and digital marketing efforts, it can really drive results.

Do note that much of what we’ll be talking about in these next two articles (yes, there is a part 4!) is more descriptive than prescriptive: think of the features we’ll discuss as more of a jazz piece than a proper arrangement. What we may describe may not be right for you or your company, but it should give you ideas and a jumping-off point to apply concepts to your own marketing efforts.

Filtering: The Best Way to Make Sense of Your Data

By default, Google Analytics comes with a filtering system of views for segregating data, but its best use is to filter signal from noise.

Setting Up Filters

With the standard “View All Web Site Data” view, you are getting just that—all website data. That means you’re also getting all of your and your company’s activity in your results. In addition to the limitations that Google Analytics has when it comes to dealing with certain traffic sources, you’re also exposed to the ever-expanding practice of referral spam (more on that here). Your best bet is to set up a filtered view that addresses some of these issues.

It is incredibly important that you do not apply your filters to your “All Web Site Data” view!

Because this is the view of the record, so to speak, we want all data to be recorded in one place, even if that’s not the one you view day-to-day. With that in mind, head to Google Analytics, click “Admin,” and head over to the view column (which will be the third column on the right.)

Click on the top drop-down arrow and you’ll see the Create New View option at the bottom of the list. Go ahead and click on that. Once you’ve reached the next screen, enter a descriptive name for the view you’re creating (I’d recommend something similar to “Internal Traffic and Spam Filtered”—something that makes the filters very clear) and, if you’ve followed the examples in the Google Analytics-Marketo Integration Guide, set the User-ID view to “On.”

The dreaded spam

Now that you have your filter set up, any new activity moving forward can be properly filtered. First, let’s start with one of the most basic issues: spam.

If you’ve looked in your referral reports lately, you’ll likely see a bunch of junk data mixed in with your actual referral data, like so:

So, let’s fix this! Go back to your Admin screen, select the view you’ve created from that same drop-down list on the right and select “Filters.” From here, we’re going to set up a series of exclusion filters, which say that any traffic that matches patterns we don’t want to see should be removed from your statistics overall.

Now, unfortunately, due to Google Analytics’ limitations on the amount of things you can exclude, we’re going to use a combination of regular expressions and multiple filters to try to remove as much as we can.

For each filter, follow these instructions, save, and create another filter.

  • Filter Name: Exclude Spam Filter #1
  • Filter Type: Custom, Exclude
  • Filter Field: Hostname
  • Filter Pattern: ^$|4webmasters
  • Filter Name: Exclude Spam Filter #2
  • Filter Type: Custom, Exclude
  • Filter Field: Campaign Source
  • Filter Pattern: arodar\.|semalt\.|buttons-for|wordpress-crew|wordpress-start|ranksonic\.|adcash\.|share.?buttons\.|social.?buttons\.|hulfingtonpost\.|free.*traffic|buy-cheap|-seo|seo-|videos-for|sitevalu|tagscan|hosting-track|your\.(web)?site$|adf\.ly|santasg|yeartwit
  • Filter Name: Exclude Spam Filter #3
  • Filter Type: Custom, Exclude
  • Filter Field: Campaign Source
  • Filter Pattern: \.?l(u|o)mb\.co$|savetubevideo\.|your.?website|sharebutton|bestwebsitesawards\.com|buy-forum\.ru|fbdownloader\.com|adviceforum\.info|errors-scanner|smailik\.org|lombia\.co|teedle|w3java|onlinetvs|uptimechecker|-stealer|googlemare|-my-site|hdmoviecamera
  • Filter Name: Exclude Spam Filter #4
  • Filter Type: Custom, Exclude
  • Filter Field: Campaign Source
  • Filter Pattern: o-o-|free-traffic|guardlan\.co|youporn-|gator-porn|prlog\.ru|mpftpupload|inboxdollar|humanorights|gobongo|forum69|cityadspix|server[-\w]{0,3}down|webmonе|buyeasy|traffic2|erot.co$|trafficmone|wpsecurity|my-site\.|rusexy|годом\.рф|nufaq|topseo|web-revenue
  • Filter Name: Exclude Spam Filter #5
  • Filter Type: Custom, Exclude
  • Filter Field: Campaign Source
  • Filter Pattern: wpthemedetect|referral.?spam|videos-for|-amezon|quick-?money|sexyali|free.*?buttons|hongfanji|buyerpricer|qualitymarketzone|clicksor|justprofit|rednise\.|search-helper\.|kings-analytic|alibestsale\.|dbutton\.|naturehelps\.me|copyrightclaims\.org|snip\.tw
  • Filter Name: Exclude Spam Filter #6
  • Filter Type: Custom, Exclude
  • Filter Field: Campaign Source
  • Filter Pattern: net-profits|trafficgenius|social.?widget|make.?money|site.?steal

(Side note: if you still see spam referrals popping up after applying these patches, you may need to manually write some exclusions yourself. Reference Google Analytics’ competitor, Piwik’s ongoing list of spam referrals to do a more in-depth sweep.)

Employee Traffic

Next, we’ll want to remove employee traffic to avoid skewing your traffic results. Start by doing a roundup of who on your team looks at your website on a regular basis and on what devices. Are they looking at work? At home? At a coffee shop?

You’ll need to account for all possibilities.

For each location from which someone views your website, have them visit WhatIsMyIP.com, which will give the user their current public-facing IP address. For instance, right now my IP is:

For companies with Internet connections, the odds are good you’ll have a static IP, meaning this address won’t change much, regardless of what device you’re using or when you connect. For website views coming from your mobile provider or your home connection, you’ll likely have a dynamic IP, meaning the last numbers in your IP address can and will change over time. To accommodate this, we’ll need to use wildcard filters.

Once you have everyone’s IP addresses, make a quick list to sort everything out. An example would look something like this:

Home: 1.2.3.4
Home: 9.10.11.12
Coffee shop: 90.120.180.240
Work: 20.40.60.80

For the first three, we’re going to remove the last octet (the number after the last period).

Go back to Google Analytics -> Admin -> Views -> Filters and create another new filter with the following information:

  • Filter Name: Employee IPs
  • Filter Type: Predefined, Exclude traffic from the IP addresses that begin with
  • Filter Field: IP Address
  • Filter Pattern: To enter your filter pattern, take your list of IPs and separate each with a pipe (|) character. In our example, the value you enter would be: 1.2.3|9.10.11|90.120.180|20.40.60.80

Then hit save.

Tracking social data

Finally, I usually like to address one of my pet peeves from my community manager days: handling social data! With the growing number of ways someone can interact with your content on social media (on the network’s main site, on an app, embedded on someone else’s site, etc.), social data needed for tracking can get improperly placed in your reports. We’ll deal with this by using one more filter.

Go to Admin -> Views -> Filters -> Create New Filter. This time around, we’re going to use a slightly different pattern.

Filter Name: Rewrite Medium for Social Referrals
Filter Type: Custom, Advanced

With the new fields that have popped up, under “Field A -> Extract A” select “Campaign Source” from the drop-down list and enter the following string:

(^t\.co$|plus\.google\.com|lnkd\.in|(twitter|facebook|linkedin|youtube|reddit|digg|delicious|stumbleupon|ycombinator|flickr|myspace|hootsuite|pinterest|buzfeed|bebo|foursquare|goodreads|instagram|tumblr|xing)\.)

Leave Field B -> Extract B blank, and then under “Output To -> Constructor,” select “Campaign Medium” and enter “social” in the textbox. Check off “Field A Required” and “Override Output Field.” Save, and you should be good to go!

Channel Grouping: Sorting Your Data Accurately

Odds are that if you’ve looked at your Referral data in Google Analytics, one of your top referrers is…your Marketo email link tracking! Unfortunately, having this data in your referral traffic tends to muddy the waters, and given how important reporting email traffic in aggregate is to most marketers, we really should make a Channel Group for this. This way, you have a brand new channel for sorting your data, like so:

To set this up, we’ll need to retrieve your Marketo email link-tracking domain. Log in to Marketo, go to Admin-> Email, and copy the value you have for “Tracking Link.” You’ll find this on the last line seen here:

From there, head back to Google Analytics and go to the Admin section again. Under the third column for your view (be sure that the view you were working on earlier to filter traffic is selected!), click on “Channel Settings” and then “Channel Groupings.” Once you do so, you’ll likely see a link called “Default Channel Grouping.” Click on that, and you’ll see a list of channels pop up!

Some of these will look familiar, such as Direct, Organic Search, and Social—but you’ll likely see some that have never come up in your reports! We’re going to take advantage of Email to sort out our Marketo email traffic. First, make sure that “Email” is listed ABOVE “Referral”; if it’s not, you’ll need to click on the dots next to the number and drag “Email” above “Referral.” The number order determines the order in which rules should be checked before applying them, just like Choices in the Marketo flow steps.

Click on the pencil to edit “Email,” and where it says “Define Rules,” click the drop-down arrow next to “System Defined Channel” and select “Source.” In the next box, select “Contains,” and in the final text box, place the Marketo tracking link you grabbed.

If you use multiple email systems, you may also want to add a second filter (the OR button to the right) and add another definition such as “Source exactly matches email.” Click “Done,” then “Save.” Any email activity moving forward should now be grouped under the Email channel.

Alternately, if you consistently tag your emails with UTM parameters, it may make more sense to remove your email referrer from your results altogether—this will result in your email’s link parameters being directly passed to Google Analytics. Simply take the tracking link you’re using from Marketo (as explained above) and go to Admin -> Tracking Info -> Referral Exclusion list to add your tracking link as an excluded domain.

You may also want to experiment with other major sources you want to break out; for instance, here at DemandLab we have a separate channel for traffic coming from our content partners at BrightInfo.

Now that we have the ability to see traffic aligned, we’re at a perfect jumping-off point for further Google Analytics-Marketo integration. Stay tuned for part 4! And if you need a refresher course in Marketo and Google Analytics integration, check out Get on the Right “Track” with UTM Tagging and The Ultimate Google Analytics and Marketo Integration Guide.