コード例 #1
0
 def get(self):
     try:
         service = GoogleAnalyticsService(self.g_credential)
         properties = service.get_all_profiles_with_properties()
     except HttpError, e:
         abort(404,
               message=json.loads(e.content).get("error").get("message"))
コード例 #2
0
 def get(self):
     args = parser.parse_args()
     service = GoogleAnalyticsService(self.g_credential)
     analytics_credential = GoogleAnalyticsCredential.get_by_user_id(
         self.g_credential.key.id())
     if not analytics_credential:
         abort(
             404,
             message=
             "there are no Google analytics account associated to this user "
         )
     profile_id = analytics_credential.profile_id
     visitors = service.get_data_by_date(profile_id, ['uniquePageViews'],
                                         ['pagePath=~welcome'],
                                         args["startDate"],
                                         args["endDate"]).get('rows')
     service = MixPanelService(config.get("mixpanel_api_key"),
                               config.get("mixpanel_api_secret"))
     new_users = service.daily_new_users(args["startDate"], args["endDate"])
     conversion_rates = []
     for index, user in enumerate(new_users):
         visitor = visitors[index]
         rate = user[0] * 100 / float(int(visitor[1]))
         item = [round(rate, 2), user[1]]
         conversion_rates.append(item)
     return {'data': conversion_rates}
コード例 #3
0
 def get(self):
     args = parser.parse_args()
     service = GoogleAnalyticsService(self.g_credential)
     analytics_credential = GoogleAnalyticsCredential.get_by_user_id(self.g_credential.key.id())
     if not analytics_credential:
         abort(404, message="there are no Google analytics account associated to this user ")
     profile_id = analytics_credential.profile_id
     data_by_source = service.get_data_by_source(profile_id, ['uniquePageViews'], ['pagePath=~welcome'],
                                                 args["startDate"],
                                                 args["endDate"]).get('rows')
     return {'data': data_by_source}
コード例 #4
0
    def get(self):
        args = parser.parse_args()
        analytics_service = GoogleAnalyticsService(self.g_credential)
        analytics_credential = GoogleAnalyticsCredential.get_by_user_id(self.g_credential.key.id())
        if not analytics_credential:
            abort(404, message="there are no Google analytics account associated to this user.")
        profile_id = analytics_credential.profile_id

        data_by_date = analytics_service.get_data_by_date(profile_id, ['bounceRate'], ['pagePath=~welcome'],
                                                          args["startDate"],
                                                          args["endDate"]).get(
            'rows')

        return {'data': prepare_response(data_by_date)}
コード例 #5
0
    def get(self):
        args = parser.parse_args()
        service = GoogleAnalyticsService(self.g_credential)
        analytics_credential = GoogleAnalyticsCredential.get_by_user_id(self.g_credential.key.id())
        if not analytics_credential:
            abort(404, message="there are no Google analytics account associated to this user ")
        profile_id = analytics_credential.profile_id

        data_by_date = service.get_data_by_date(profile_id, ['uniquePageViews'], ['pagePath=~welcome'],
                                                args["startDate"],
                                                args["endDate"]).get('rows')
        result = []
        for row in data_by_date:
            date = datetime.strptime(row[0], '%Y%m%d')
            result.append([row[1], str(date)])
        return {'data': result}
コード例 #6
0
 def get(self):
     args = parser.parse_args()
     service = GoogleAnalyticsService(self.g_credential)
     analytics_credential = GoogleAnalyticsCredential.get_by_user_id(
         self.g_credential.key.id())
     if not analytics_credential:
         abort(
             404,
             message=
             "there are no Google analytics account associated to this user "
         )
     profile_id = analytics_credential.profile_id
     data_by_source = service.get_data_by_source(
         profile_id, ['uniquePageViews'], ['pagePath=~welcome'],
         args["startDate"], args["endDate"]).get('rows')
     return {'data': data_by_source}
コード例 #7
0
 def get(self):
     args = parser.parse_args()
     service = GoogleAnalyticsService(self.g_credential)
     analytics_credential = GoogleAnalyticsCredential.get_by_user_id(self.g_credential.key.id())
     if not analytics_credential:
         abort(404, message="there are no Google analytics account associated to this user ")
     profile_id = analytics_credential.profile_id
     visitors = service.get_data_by_date(profile_id, ['uniquePageViews'], ['pagePath=~welcome'], args["startDate"],
                                         args["endDate"]).get('rows')
     service = MixPanelService(config.get("mixpanel_api_key"), config.get("mixpanel_api_secret"))
     new_users = service.daily_new_users(args["startDate"], args["endDate"])
     conversion_rates = []
     for index, user in enumerate(new_users):
         visitor = visitors[index]
         rate = user[0] * 100 / float(int(visitor[1]))
         item = [round(rate, 2), user[1]]
         conversion_rates.append(item)
     return {'data': conversion_rates}
コード例 #8
0
    def get(self):
        args = parser.parse_args()
        analytics_service = GoogleAnalyticsService(self.g_credential)
        analytics_credential = GoogleAnalyticsCredential.get_by_user_id(
            self.g_credential.key.id())
        if not analytics_credential:
            abort(
                404,
                message=
                "there are no Google analytics account associated to this user."
            )
        profile_id = analytics_credential.profile_id

        data_by_date = analytics_service.get_data_by_date(
            profile_id, ['bounceRate'], ['pagePath=~welcome'],
            args["startDate"], args["endDate"]).get('rows')

        return {'data': prepare_response(data_by_date)}
コード例 #9
0
    def get(self):
        args = parser.parse_args()
        service = GoogleAnalyticsService(self.g_credential)
        analytics_credential = GoogleAnalyticsCredential.get_by_user_id(
            self.g_credential.key.id())
        if not analytics_credential:
            abort(
                404,
                message=
                "there are no Google analytics account associated to this user "
            )
        profile_id = analytics_credential.profile_id

        data_by_date = service.get_data_by_date(profile_id,
                                                ['uniquePageViews'],
                                                ['pagePath=~welcome'],
                                                args["startDate"],
                                                args["endDate"]).get('rows')
        result = []
        for row in data_by_date:
            date = datetime.strptime(row[0], '%Y%m%d')
            result.append([row[1], str(date)])
        return {'data': result}
コード例 #10
0
 def get(self):
     try:
         service = GoogleAnalyticsService(self.g_credential)
         properties = service.get_all_profiles_with_properties()
     except HttpError, e:
         abort(404, message=json.loads(e.content).get("error").get("message"))