示例#1
0
# Video Views query
CONTAINER = GAQueryContainer()

# version 1
BASE = GAQueryBase(dimensions='ga:pagePath',
                   metrics='ga:pageviews',
                   sort='ga:pagePath',
                   filters=';'.join(
                       (fil.CTYPE_VIDEO, fil.PATH_TO_CONTENT_LAUNCH)),
                   view_name_includes='Report Data')

CONTAINER.add(
    GAQueryDefinition(BASE,
                      'videoviews',
                      title='Video Views',
                      effective_date=config.EARLIEST_REPORT_DATE,
                      termination_date=datetime.date(2015, 10, 31),
                      has_webproperty_sum=True,
                      show_rows=False))

# version 2
BASE.filters = ';'.join((fil.CTYPE_VIDEO, fil.PATH_TO_CONTENT))

CONTAINER.add(
    GAQueryDefinition(BASE,
                      'videoviews',
                      title='Video Views',
                      effective_date=datetime.date(2015, 11, 1),
                      mysql_table=config.MONTHLY_REPORT_TABLE,
                      has_webproperty_sum=True,
                      show_rows=False))
示例#2
0

CONTAINER = GAQueryContainer()

# version 1
BASE = GAQueryBase(
    dimensions=ga.LANGUAGE,
    metrics='ga:pageviews',
    filters=';'.join((fil.READS_V1, fil.VISITOR_COUNTRIES)), 
    view_name_includes='Report Data'
)

CONTAINER.add(GAQueryDefinition(BASE, 'pacomreads',
    title='Article Reads in the PACOM AoR',
    effective_date=   config.EARLIEST_REPORT_DATE,
    termination_date= datetime.date(2015, 10, 31),
    show_rows=False,
    has_webproperty_sum=True
))

# version 2
BASE.filters = ';'.join((fil.READS_V2, fil.VISITOR_COUNTRIES))

CONTAINER.add(GAQueryDefinition(BASE, 'pacomreads', 
    title='Article Reads in the PACOM AoR',
    effective_date=   datetime.date(2015, 11, 1),
    termination_date= datetime.date(2016, 5, 31),
    show_rows=False,
    has_webproperty_sum=True
))
# Proxy network article reads by city query

# version 1
CONTAINER = GAQueryContainer()
BASE = GAQueryBase(dimensions='ga:city,ga:country',
                   metrics='ga:pageviews',
                   sort='ga:pageviews',
                   filters=';'.join(
                       (fil.READS_V3, 'ga:networkDomain==opera-mini.net')),
                   view_name_includes='Report Data')
CONTAINER.add(
    GAQueryDefinition(BASE,
                      'proxyreadsbycity',
                      title='Article Reads from Proxy Networks by City',
                      effective_date=config.EARLIEST_REPORT_DATE,
                      termination_date=datetime.date(2016, 9, 30),
                      show_rows=True,
                      has_webproperty_sum=True,
                      total_only=True))

# version 2
BASE.filters = ';'.join((fil.READS_V3, 'ga:browser==Opera Mini'))

CONTAINER.add(
    GAQueryDefinition(BASE,
                      'proxyreadsbycity',
                      title='Article Reads from Proxy Networks by City',
                      effective_date=datetime.date(2016, 10, 1),
                      show_rows=True,
                      has_webproperty_sum=True,
                      total_only=True))
示例#4
0
import sys, os
sys.path.append(os.path.realpath(''))
import datetime

import googleanalytics.metric_strings as ga
import googleanalytics.filter_strings as fil
from googleanalytics.query import GAQueryBase, GAQueryDefinition, GAQueryContainer

CONTAINER = GAQueryContainer()

# version 1 (no legacy versions have been added)
BASE = GAQueryBase(dimensions=ga.THEME,
                   metrics='ga:pageviews',
                   sort='-ga:pageviews',
                   filters=fil.READS_V3,
                   view_name_includes='Report Data')

CONTAINER.add(
    GAQueryDefinition(BASE,
                      'readsbytheme',
                      title='Article Reads by Theme',
                      effective_date=datetime.date(2016, 6, 1),
                      group_by=ga.THEME,
                      show_rows=True,
                      total_only=True))
示例#5
0
but they're greater than the number in Debug Data, which doesn't make sense,
so it's recommended to use Debug Data numbers from May 21-23.''')

# version 2 base
BASE_V2 = copy.deepcopy(BASE_V1)
BASE_V2.view_name_includes = 'Report Data'
BASE_V2.comment = None

CONTAINER = GAQueryContainer()

# version 1 definition
CONTAINER.add(
    GAQueryDefinition(BASE_V1,
                      'pageviews',
                      title='Overall Page Views',
                      effective_date=config.EARLIEST_REPORT_DATE,
                      termination_date=datetime.date(2015, 5, 23),
                      has_webproperty_sum=True,
                      show_rows=False))

# version 2 definition
CONTAINER.add(
    GAQueryDefinition(BASE_V2,
                      'pageviews',
                      title='Overall Page Views',
                      effective_date=datetime.date(2015, 5, 24),
                      termination_date=datetime.date(2017, 7, 31),
                      has_webproperty_sum=True,
                      show_rows=False))

# version 3 definition
示例#6
0
    dimensions='ga:date',
    metrics=UNIQUE_VISITORS,
    sort='ga:date',
    view_name_includes='Report Data',
    comment='''Calculations.ods instructions:
1) Paste rows into a scratch sheet.
2) Use space as a delimiter (otherwise, OpenOffice will
   insert single quotes in front of the numbers).
3) Verify that the dates are correctly ordered.
4) Paste the metric values into Calculations.ods.'''
)

CONTAINER.add(GAQueryDefinition(query_base, 'dailyvisitors',
    title='Daily Unique Visitors',
    daily_metric=True,
    show_rows=True,
    has_webproperty_sum=False,
    include_total=True,
    row_sort_index=0
))


# Philippines sub-webproperty filters:

# WARNING:
#    Do not alter these filters in an attempt to capture "lost" visitors
#    to non-sectioned pages. In the case of Unique Visitors, there's no
#    way to do it without the risk of overcounting. It may be possible with
#    New Visitors, but even so, it amounts to having two visitors metrics
#    that apply to different parts of the website. Also, the "loss" of
#    visitors was at most half a percent when last checked.
示例#7
0
CONTAINER = GAQueryContainer()

# version 1
BASE = GAQueryBase(
    dimensions='ga:country',
    metrics='ga:pageviews',
    sort='ga:country',
    filters=';'.join((fil.READS_V1, 'ga:country==(not set)')),
    view_name_includes='Report Data'
)

CONTAINER.add(GAQueryDefinition(BASE, 'unknownreads', 
    title='Article Reads Not Identified by Country',
    effective_date=   config.EARLIEST_REPORT_DATE,
    termination_date= datetime.date(2015, 10, 31),
    show_rows=False,
    has_webproperty_sum=False,
    country='(not set)'
))

# version 2
BASE.filters = ';'.join((fil.READS_V2, 'ga:country==(not set)'))

CONTAINER.add(GAQueryDefinition(BASE, 'unknownreads', 
    title='Article Reads Not Identified by Country',
    effective_date=   datetime.date(2015, 11, 1),
    termination_date= datetime.date(2016, 5, 31),
    show_rows=False,
    has_webproperty_sum=False,
    country='(not set)'
))
示例#8
0
import googleanalytics.metric_strings as ga
from googleanalytics.custom_filter import CustomQueryFilter
from googleanalytics.query import GAQueryBase, GAQueryDefinition, GAQueryContainer

NEW_VISITORS = 'ga:newUsers'

CONTAINER = GAQueryContainer()

query_base = GAQueryBase(dimensions='ga:year',
                         metrics=NEW_VISITORS,
                         view_name_includes='Report Data')

CONTAINER.add(
    GAQueryDefinition(query_base,
                      'newvisitors',
                      title='New Visitors for running totals',
                      termination_date=datetime.date(2017, 7, 31),
                      include_total=True,
                      show_rows=False))

CONTAINER.add(
    GAQueryDefinition(query_base,
                      'newvisitors',
                      title='New Visitors for running totals',
                      effective_date=datetime.date(2017, 8, 1),
                      include_total=True,
                      show_rows=False,
                      has_report_lines=True,
                      mysql_table=config.MONTHLY_REPORT_TABLE))

# Philippines sub-webproperty filters:
示例#9
0
# Unique Visitors for Report Period query
CONTAINER = GAQueryContainer()

# version 1
BASE = GAQueryBase(dimensions='ga:date',
                   metrics=OLD_UNIQUE_VISITORS,
                   max_results=None,
                   sort=None,
                   filters=None,
                   view_name_includes='Report Data')

CONTAINER.add(
    GAQueryDefinition(BASE,
                      'visitors',
                      title='Unique Visitors for report period',
                      effective_date=config.EARLIEST_REPORT_DATE,
                      termination_date=datetime.date(2016, 1, 31),
                      show_rows=False,
                      has_webproperty_sum=False,
                      include_total=True))

# version 2
BASE.dimensions = 'ga:year'
BASE.metrics = UNIQUE_VISITORS

CONTAINER.add(
    GAQueryDefinition(BASE,
                      'visitors',
                      title='Unique Visitors for report period',
                      effective_date=datetime.date(2016, 2, 1),
                      termination_date=datetime.date(2017, 7, 31),
                      show_rows=False,
示例#10
0
metric, as seen in the summary stats - hence the use of
different GA query filters between this and the
Article Reads query.

Warning: any metric that uses Article UID cannot be used to
collect data before September 2015, because UIDs were
implemented in August.''')

CONTAINER.add(
    GAQueryDefinition(main_base,
                      'toparticles',
                      title='Top 10 Read Articles',
                      effective_date=config.EARLIEST_REPORT_DATE,
                      termination_date=datetime.date(2016, 5, 31),
                      join_queries=[join1_base, join2_base],
                      mysql_table=config.ARTICLE_METRIC_TABLE,
                      metric_index=2,
                      show_rows=True,
                      has_row_sum=False,
                      has_webproperty_sum=False,
                      has_report_tables=True,
                      max_rows_to_print=10,
                      include_total=False))

# version 2

main_base = copy.deepcopy(main_base)
main_base.filters = fil.ARTICLE_AND_SLIDESHOW_READS

CONTAINER.add(
    GAQueryDefinition(
        main_base,
示例#11
0
BASE = GAQueryBase(dimensions='ga:date',
                   metrics='ga:pageviews',
                   max_results=None,
                   sort='ga:date',
                   filters=';'.join(
                       (fil.CTYPE_ARTICLE, fil.SLIDESHOW_NOT_ARTICLE,
                        fil.PATH_TO_CONTENT_LAUNCH)),
                   view_name_includes='Report Data',
                   comment=None)

CONTAINER.add(
    GAQueryDefinition(BASE,
                      'slideshowviews',
                      title='Slideshow Views',
                      effective_date=config.EARLIEST_REPORT_DATE,
                      termination_date=datetime.date(2015, 10, 31),
                      has_webproperty_sum=True,
                      show_rows=False))

# version 2:

BASE.filters = ';'.join(
    (fil.CTYPE_ARTICLE, fil.SLIDESHOW_NOT_ARTICLE, fil.PATH_TO_CONTENT_Y15))

CONTAINER.add(
    GAQueryDefinition(BASE,
                      'slideshowviews',
                      title='Slideshow Views',
                      effective_date=datetime.date(2015, 11, 1),
                      termination_date=datetime.date(2016, 5, 31),
示例#12
0
import sys, os
sys.path.append(os.path.realpath(''))
import datetime

import googleanalytics.metric_strings as ga
import googleanalytics.filter_strings as fil
from googleanalytics.query import GAQueryBase, GAQueryDefinition, GAQueryContainer

# Cities by Article Reads (Global) query
CONTAINER = GAQueryContainer()

# version 1 (no legacy versions have been added)
BASE = GAQueryBase(dimensions='ga:city,ga:country',
                   metrics='ga:pageviews',
                   sort='-ga:pageviews',
                   filters=fil.READS_V3,
                   max_results=15,
                   view_name_includes='Report Data')

CONTAINER.add(
    GAQueryDefinition(BASE,
                      'readsbycity',
                      title='Cities by Article Reads, Global',
                      effective_date=datetime.date(2016, 6, 1),
                      show_rows=True,
                      total_only=True))
示例#13
0
import sys, os
sys.path.append(os.path.realpath(''))
import datetime

import googleanalytics.metric_strings as ga
import googleanalytics.filter_strings as fil
from googleanalytics.query import GAQueryBase, GAQueryDefinition, GAQueryContainer

CONTAINER = GAQueryContainer()

# version 1 (no legacy versions have been added)
BASE = GAQueryBase(
    dimensions='ga:country',
    metrics='ga:pageviews',
    sort='-ga:pageviews',
    filters=fil.READS_V3,
    max_results=
    300,  # queries all countries to prevent data loss when grouping across ReportSegments
    view_name_includes='Report Data')

CONTAINER.add(
    GAQueryDefinition(BASE,
                      'readsbycountry',
                      title='Countries by Article Reads',
                      effective_date=datetime.date(2016, 6, 1),
                      group_by='ga:country',
                      show_rows=True,
                      max_rows_to_print=12,
                      total_only=True))
示例#14
0
import sys, os
sys.path.append(os.path.realpath(''))
import datetime

import googleanalytics.metric_strings as ga
import googleanalytics.filter_strings as fil
from googleanalytics.query import GAQueryBase, GAQueryDefinition, GAQueryContainer

# Cities by Article Reads (PACOM AoR) query
CONTAINER = GAQueryContainer()

# version 1 (no legacy versions have been added)
BASE = GAQueryBase(dimensions='ga:city,ga:country',
                   metrics='ga:pageviews',
                   sort='-ga:pageviews',
                   filters=';'.join((fil.READS_V3, fil.VISITOR_COUNTRIES)),
                   max_results=15,
                   view_name_includes='Report Data')

CONTAINER.add(
    GAQueryDefinition(BASE,
                      'readsbycitypacom',
                      title='Cities by Article Reads, PACOM AoR',
                      effective_date=datetime.date(2016, 6, 1),
                      show_rows=True))
示例#15
0
                   sort='ga:date',
                   filters=fil.READS_V1,
                   view_name_includes='Report Data',
                   comment='''Calculations.ods instructions:
1) Paste rows into a scratch sheet.
2) Use space as a delimiter (otherwise, OpenOffice will
   insert single quotes in front of the numbers).
3) Verify that the dates are correctly ordered.
4) Paste the metric values into Calculations.ods.''')

CONTAINER.add(
    GAQueryDefinition(BASE,
                      'dailyreads',
                      title='Daily Article Reads',
                      effective_date=config.EARLIEST_REPORT_DATE,
                      termination_date=datetime.date(2015, 10, 31),
                      daily_metric=True,
                      show_rows=True,
                      include_total=False,
                      has_webproperty_sum=False))

# version 2
BASE.filters = fil.READS_V2

CONTAINER.add(
    GAQueryDefinition(BASE,
                      'dailyreads',
                      title='Daily Article Reads',
                      effective_date=datetime.date(2015, 11, 1),
                      termination_date=datetime.date(2016, 5, 31),
                      daily_metric=True,