def report_view(client_id, path, language, headers): host_name = headers.get('HTTP_HOST', None) referrer = headers.get('HTTP_REFERER', None) pv = ga.PageView(path, host_name=host_name, referrer=referrer) extra_info = ga.SystemInfo(language=language) extra_headers = {} """ if '/products/' in path and '/category/' not in path and '.jpg' not in path and '.png' not in path: print('here') extra_info = [{'ecommerce': { 'detail': { 'actionField': {'list': 'Apparel Gallery'}, 'products': [{ 'name': 'Triblend Android T-Shirt', 'id': '12345', 'price': '15.25', 'brand': 'Google', 'category': 'Apparel', 'variant': 'Gray' }] }}}] """ user_agent = headers.get('HTTP_USER_AGENT', None) if user_agent: extra_headers['user-agent'] = user_agent _report(client_id, pv, extra_info=extra_info, extra_headers=extra_headers) """
def report_view(client_id, path, language, headers): host_name = headers.get('HTTP_HOST', None) referrer = headers.get('HTTP_REFERER', None) pv = ga.PageView(path, host_name=host_name, referrer=referrer) extra_info = ga.SystemInfo(language=language) extra_headers = {} user_agent = headers.get('HTTP_USER_AGENT', None) if user_agent: extra_headers['user-agent'] = user_agent _report(client_id, pv, extra_info=extra_info, extra_headers=extra_headers)
def exit_redirect(): rawurl = request.args.get('u', 'https://search.openoil.net') newurl = urllib.parse.unquote(rawurl) # XXX tracking happens here, right? user_id = request.cookies.get('oo_search_user', 'unknown user') ua = app.config.get('GOOGLE_ANALYTICS_UA') view = google_measurement_protocol.PageView(path=request.url, referrer=request.referrer) google_measurement_protocol.report(ua, user_id, view) return redirect(newurl)
def gmp_report_pageview(self, client_id, path=None, title=None): """Send GMP Pageview.""" tid = self.settings["TID"] gmp.report(tid, client_id, gmp.PageView(path=path, title=title))