Skip to content

Django app used to pull daily Google Analytics data into your django database.

License

Notifications You must be signed in to change notification settings

CIGIHub/django-ga-puller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-ga-puller

Django app used to pull daily Google Analytics data into your django database. It provides abstract models which you should inherit from in your app.

To Use

Add the app to your settings.py file:

INSTALLED_APPS = [...
                  'ga_puller',
                  ...]

In your app,

Create models that inherit from the abstract classes provided. Here is a sample of a basic implementation:

from ga_puller.models import AnalyticsPage, DailyEventTrackingBase, DailyPageTrackingBase

class Page(AnalyticsPage):

    def __unicode__(self):
        return "%s" % self.page_path


class DailyEventData(DailyEventTrackingBase):

    page = models.ForeignKey('Page')
    
    @classmethod
    def get_page_class(cls):
        return Page


class DailyPageTrackingData(DailyPageTrackingBase):

    page = models.ForeignKey('Page')
    
    @classmethod
    def get_page_class(cls):
        return Page

Add a list named analytics_import_models defining the data models to the init.py of your app module:

from models import DailyPageTrackingData, DailyEventData
analytics_import_models = [DailyPageTrackingData, DailyEventData]

Create a 'private' python package at the root level of your django project (at the same level as the manage.py file).

The application requires a service account for authentication with Google. These can be configured by logging into your account at https://cloud.google.com.

Copy your Google API private key file to the private directory (name it privatekey.pem).

Add django settings:

service_account = '[email protected]'
view_ids = {'app_name': '#########', ...}

This package uses Google APIs Client Library for Python which should automatically be installed through setup.

Release Notes:

0.1.0: Initial Release 0.1.1: Updated to support importing from separate views in google analytics. 0.1.2: Increased the size of the label and page_path fields. 0.1.5: Removed the accounts.py file and moved the data into the django settings file.

About

Django app used to pull daily Google Analytics data into your django database.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages