def get(self):
     resp = {'google_analytics': None}
     analytics_credential = GoogleAnalyticsCredential.get_by_user_id(
         self.g_credential.key.id())
     if analytics_credential:
         resp['google_analytics'] = analytics_credential.profile_id
     return resp
 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}
 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}
    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)}
    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}
 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}
 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}
    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)}
    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}
Esempio n. 10
0
 def get(self):
     resp = {'google_analytics': None}
     analytics_credential = GoogleAnalyticsCredential.get_by_user_id(self.g_credential.key.id())
     if analytics_credential:
         resp['google_analytics'] = analytics_credential.profile_id
     return resp
 def post(self):
     args = parser.parse_args()
     GoogleAnalyticsCredential(google_credential=self.g_credential.key,
                               profile_id=args["profile_id"]).put()
     return {'profile_id': args["profile_id"]}, 201