Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
728 views
in Technique[技术] by (71.8m points)

ios - Create a Google Analytics view filter that excludes hits with missing fields

I have a mobile iOS app that uses Google Analytics.

Recently I have been receiving hits in my reports that are clearly not coming from my app. I guess someone must be using my tracker ID (I hope, by mistake).

So I've been trying to create a filtered view that doesn't include this traffic. My first approach was to create an include filter on the applicationID field, hoping that would filter out any hit that doesn't have the right applicationID. When using the Google Analytics iOS SDK, this field is always set with the app bundle identifier, so it is highly improbable - if not impossible - that a hit sent by mistake by someone else will have the correct value.

It didn't work, and after wondering why for days, I just found out. The document about view filters (https://support.google.com/analytics/answer/1033162) actually says : "Fields specified in a filter must exist in the hit and not be null in order for the filter to be applied to that hit". So I can't have filters on missing fields, which is a problem because those unwanted hits I'm receiving seems to have all of their fields empty.

Which leads me to ask : Has anyone ever had this problem before ? And if yes, what is your approach ?

Currently I am using an unfiltered view with a custom segment that does the work (because the filtering of empty fields is doable using segments). But I would like to have a filtered view on which I could apply real segments.

Thanks for your insights

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I don't have a mobile view to test with, but based on web tracking the following seems to work:

  • Create a new filter, custom, advanced
  • Field A : Application ID
  • Extract A : (.*)
  • Field B : leave empty
  • Output to : Custom field 1
  • Constructor : $A1
  • Make sure that "Field A required" and "Override Output Field" are checked

  • Create a second filter, custom, include

  • Filter field : Custom Field 1
  • Filter Pattern : Your application bundle ID (e.g : com.mycompany.MyAppName)

It seems advanced filters do recognize if a field is empty via the "Field Required" setting. So the custom field is set only when the field is not empty, and you can subsequently use a second filter to include only visits that have the field set (thereby excluding hits that haven't the field set)

To illustrate my less than brilliant instructions, the following worked for me:

First Filter


Second Filter


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...