Ariel Yosef
Ariel Yosef

Reputation: 23

Google Analytics - Python API

I'm using Python to extract data from Google Analytics API, I use dimensionFilterClauses for filtering out specific value, does anyone know what is the operator for such filter? (the opposite of 'Exact')

Here is the example of the working Exact:

"dimensionFilterClauses": [
{
  "filters": [
      {
       "dimensionName": "ga:eventCategory",
       "operator": "EXACT",
       "expressions": ["Operational Events"]
}]}],

Thanks!

Upvotes: 2

Views: 962

Answers (2)

CharlieH
CharlieH

Reputation: 1542

If you are just trying to filter out events by their category, I believe you just need to add the "not" field:

"dimensionFilterClauses": [
{
  "filters": [
      {
       "dimensionName": "ga:eventCategory",
       "operator": "EXACT",
       "not": "true",
       "expressions": ["Operational Events"]
}]}],

Upvotes: 0

Matt
Matt

Reputation: 5168

There are the following options for operator:

  • OPERATOR_UNSPECIFIED If the match type is unspecified, it is treated as a REGEXP.
  • REGEXP The match expression is treated as a regular expression. All match types are not treated as regular expressions.
  • BEGINS_WITH Matches the value which begin with the match expression provided.
  • ENDS_WITH Matches the values which end with the match expression provided.
  • PARTIAL Substring match.
  • EXACT The value should match the match expression entirely.
  • NUMERIC_EQUAL - Integer comparison filters. case sensitivity is ignored for these and the expression is assumed to be a string representing an integer. Failure conditions:

    • If expression is not a valid int64, the client should expect an error.
    • Input dimensions that are not valid int64 values will never match the filter.
  • NUMERIC_GREATER_THAN - Checks if the dimension is numerically greater than the match expression. Read the description for NUMERIC_EQUALS for restrictions.
  • NUMERIC_LESS_THAN Checks if the dimension is numerically less than the match expression. Read the description for NUMERIC_EQUALS for restrictions.
  • IN_LIST This option is used to specify a dimension filter whose expression can take any value from a selected list of values. This helps avoiding evaluating multiple exact match dimension filters which are OR'ed for every single response row. For example:

    • expressions: ["A", "B", "C"] - Any response row whose dimension has it is value as A, B or C, matches this DimensionFilter.

Upvotes: 1

Related Questions