获取Flask请求的引荐网址 [英] Get referring URL for Flask request

查看:58
本文介绍了获取Flask请求的引荐网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户访问我们的网站并注册时,如何捕获他们来自哪个网站?

When a user visits our site and signs up, how can I capture which website they came from?

无论是搜索,公共关系网站等.我不在乎他们访问了我们网站上的哪个页面,我只想知道哪些营销努力为我们提供了最多的注册机会.

Be it search, a PR website, etc. I don't care what page from our site they visited, I just want to know which marketing efforts are giving us the most signups.

我知道Google Analytics(分析)可以做到这一点,但我也想提供一些内部参考.

I know Google Analytics can probably do this but I'd like to have something internal for reference as well.

推荐答案

request.referrer 包含请求来自的URL,尽管由于各种原因客户端可能未发送该请求.

request.referrer contains the URL the request came from, although it might not be sent by the client for various reasons.

该属性从Referer(不是拼写错误!)标头中获取其值:

The attribute takes its value from the Referer (not a typo!) header:

referrer = request.headers.get("Referer")

或使用Flask快捷方式:

or, using the Flask shortcut:

referrer = request.referrer

请参见本教程例如.

这篇关于获取Flask请求的引荐网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆