예제 #1
0
import sys, os
sys.path.append(os.path.realpath(''))
import datetime

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

# 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))
예제 #2
0
sys.path.append(os.path.realpath(''))
import datetime

import core.config as config
import googleanalytics.metric_strings as ga
import googleanalytics.filter_strings as fil
from googleanalytics.custom_filter import CustomQueryFilter
from googleanalytics.query import GAQueryBase, GAQueryDefinition, GAQueryContainer


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', 
예제 #3
0
import sys, os
sys.path.append(os.path.realpath(''))
import datetime

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

# 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'))
예제 #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
sys.path.append(os.path.realpath(''))
import copy
import datetime

import core.config as config
import googleanalytics.metric_strings as ga
import googleanalytics.filter_strings as fil
from googleanalytics.custom_filter import CustomQueryFilter
from googleanalytics.query import GAQueryBase, GAQueryDefinition, GAQueryContainer

# version 1 base
BASE_V1 = GAQueryBase(
    dimensions='ga:date',
    metrics='ga:pageviews',
    sort='ga:date',
    filters=fil.PATH_NOT_UNDEFINED,
    view_name_includes='Debug Data',
    comment='''There are pageviews under Report Data from May 21-23,
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,
예제 #6
0
from googleanalytics.custom_filter import CustomQueryFilter
from googleanalytics.query import GAQueryBase, GAQueryDefinition, GAQueryContainer


# to clarify the meaning of "unique":
UNIQUE_VISITORS = 'ga:users'


CONTAINER = GAQueryContainer()

query_base = GAQueryBase(
    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
))
예제 #7
0
import datetime

import core.config as config
import googleanalytics.metric_strings as ga
import googleanalytics.filter_strings as fil
from googleanalytics.custom_filter import CustomQueryFilter
from googleanalytics.query import GAQueryBase, GAQueryDefinition, GAQueryContainer


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)'))
예제 #8
0
import sys, os
sys.path.append(os.path.realpath(''))
import datetime

import core.config as config
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,
예제 #9
0
import core.config as config
import googleanalytics.metric_strings as ga
from googleanalytics.custom_filter import CustomQueryFilter
from googleanalytics.query import GAQueryBase, GAQueryDefinition, GAQueryContainer

# constants to clarify the meaning of "unique":
OLD_UNIQUE_VISITORS = 'ga:newUsers'  # replaced by UNIQUE_VISITORS as of February 2016
UNIQUE_VISITORS = 'ga:users'

# 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'
예제 #10
0
import core.config as config
import googleanalytics.metric_strings as ga
import googleanalytics.filter_strings as fil
from googleanalytics.custom_filter import CustomQueryFilter
from googleanalytics.query import GAQueryBase, GAQueryDefinition, GAQueryContainer

CONTAINER = GAQueryContainer()

# version 1 (join queries)

join1_base = GAQueryBase(
    dimensions='%s,%s,%s,%s' %
    (ga.ARTICLE_UID, ga.HEADLINE, ga.PUBLICATION_DATE, 'ga:pagePath'),
    metrics='ga:pageviews',
    max_results=
    150,  # needs lots of extra rows in order to map properly to Facebook data
    sort='-ga:pageviews',
    filters=fil.ARTICLE_AND_SLIDESHOW_READS,
    view_name_includes='Report Data')

join2_base = GAQueryBase(
    dimensions='%s,%s' % (ga.ARTICLE_UID, ga.ARTICLE_CMSID),
    metrics='ga:pageviews',
    max_results=
    150,  # needs lots of extra rows in order to map properly to Facebook data
    sort='-ga:pageviews',
    filters=fil.ARTICLE_AND_SLIDESHOW_READS,
    view_name_includes='Report Data',
    comment='''CMS ID is a separate join, because it was only recently
added to Google Analytics, and some stories won't have it.''')
예제 #11
0
import core.config as config
import googleanalytics.metric_strings as ga
import googleanalytics.filter_strings as fil
from googleanalytics.custom_filter import CustomQueryFilter
from googleanalytics.query import GAQueryBase, GAQueryDefinition, GAQueryContainer

# Slideshow Views query
CONTAINER = GAQueryContainer()

# version 1:

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:
예제 #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
import core.config as config
import googleanalytics.metric_strings as ga
import googleanalytics.filter_strings as fil
from googleanalytics.custom_filter import CustomQueryFilter
from googleanalytics.query import GAQueryBase, GAQueryDefinition, GAQueryContainer

CONTAINER = GAQueryContainer()

# version 1
BASE = GAQueryBase(dimensions='%s,ga:date' % ga.LANGUAGE,
                   metrics='ga:pageviews',
                   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,