Pulls data in from an account and returns a processed data structure for easy post processing. This method requires the following inputs: ** Required Arguments ** ``start_date`` A ``datetime`` object for the lower bound of your query ``end_date`` A `
(self, start_date, end_date, dimensions=[], metrics=[], sort=[], filters=[], start_index=0, max_results=0)
| 33 | return '<Account: %s>' % self.table_id |
| 34 | |
| 35 | def get_data(self, start_date, end_date, dimensions=[], metrics=[], sort=[], filters=[], start_index=0, max_results=0): |
| 36 | """ |
| 37 | Pulls data in from an account and returns a processed data structure for |
| 38 | easy post processing. This method requires the following inputs: |
| 39 | |
| 40 | ** Required Arguments ** |
| 41 | |
| 42 | ``start_date`` |
| 43 | A ``datetime`` object for the lower bound of your query |
| 44 | |
| 45 | ``end_date`` |
| 46 | A ``datetime`` object for the upper bound of your query |
| 47 | |
| 48 | ** Optional Arguments ** |
| 49 | |
| 50 | ``dimensions`` |
| 51 | A list of dimensions, for example: ['country','browser'] |
| 52 | |
| 53 | See: http://code.google.com/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.html |
| 54 | See: http://code.google.com/apis/analytics/docs/gdata/gdataReference.html#dimensionsAndMetrics |
| 55 | |
| 56 | ``metrics`` |
| 57 | A list of metrics, for example: ['pageviews', 'uniquePageviews'] |
| 58 | |
| 59 | See: http://code.google.com/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.html |
| 60 | See: http://code.google.com/apis/analytics/docs/gdata/gdataReference.html#dimensionsAndMetrics |
| 61 | |
| 62 | ``sort`` |
| 63 | A list of dimensions or metrics to sort the output by, should probably |
| 64 | be one of the items you specified in ``dimensions`` or ``metrics``. |
| 65 | For example: ['browser', 'pageviews'] |
| 66 | |
| 67 | See: http://code.google.com/apis/analytics/docs/gdata/gdataReference.html#sorting |
| 68 | |
| 69 | ``filters`` |
| 70 | A list of filters. A filter expression has three parts: |
| 71 | |
| 72 | name - The name of the dimension or metric to filter on. |
| 73 | For example: ga:pageviews will filter on the pageviews metric. |
| 74 | operator - Defines the type of filter match to use. Operators are |
| 75 | specific to either dimensions or metrics. |
| 76 | expression - States the values included or excluded from the results. |
| 77 | Expressions use regular expression syntax. |
| 78 | |
| 79 | Learn more about valid operators and expressions here: |
| 80 | http://code.google.com/apis/analytics/docs/gdata/gdataReference.html#filtering |
| 81 | |
| 82 | The ``filters`` input accepts this data as a list of lists like so. Please |
| 83 | note that order matters, especially when using boolean operators (see |
| 84 | below). |
| 85 | |
| 86 | [ |
| 87 | ['browser', '=~', 'Firefox', 'AND'], # Regular expression match on 'Firefox' |
| 88 | ['browser', '=~', 'Internet (Explorer|Exploder)', 'OR'], |
| 89 | ['city', '=@', 'York', 'OR'], # All cities with York as a substring |
| 90 | ['state', '!=', 'California', 'AND'], # Everything but California |
| 91 | ['timeOnPage', '<', '10'], # Reject results where timeonpage < 10sec |
| 92 | ] |