Closed (won't fix)
Project:
Token
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
18 Jun 2013 at 02:02 UTC
Updated:
6 Oct 2021 at 08:25 UTC
Jump to comment: Most recent
Comments
Comment #1
acHuge +1 for this
Comment #2
vacilando commentedhttps://drupal.org/project/google_analytics_referrer provides a tag that displays a list of referrers for the given page. If just one referrer is needed, for the given page, the syntax is [gar||1].
If there is interest, a real token could be added — just add an request in the module's issue queue.
[EDIT] On a second thought, I realize that for the given use case the referer needs to be available immediately while the fetching from Google Analytics (in the GAR module) takes time.
Comment #3
liquidcms commentedsomewhat related.. i posted this a while back: https://www.drupal.org/node/2010898#comment-9231971
Comment #4
dehacker commentedSupport for php variables %server[HTTP_REFERER] and %server[HTTP_USER_AGENT] were extremely useful in webform 3.
Some of our systems using Webform 3 can not be simply upgraded to Webform 4 because they rely on these variables for workflow in both helpdesk forms and applicant tracking. Webform 4 is dependent on the Token module to accomplish what server variables used to. As Webform is one of the most popular contrib modules it would be more robust if functionality were supported across Drupal 7 when updates are made to major modules with dependencies. Please add tokens for these server variables.
Comment #5
Chewits commentedI'm seeking for replacement of %server[HTTP_REFERER] in Webform too..
Comment #6
helmo commentedHere's a bit of code to add such tokens.... These two hooks can be added to your own custom module by replacing 'mytoken_custom' with your module name.
Comment #7
jiv_e commentedI believe this solves the issue. Please reopen if you feel this is not the case!
Comment #8
bisonbleu commented@helmo, once the suggested code in #6 is implemented in a custom module, how can I access these new tokens in e.g. Rules or elsewhere ?
Comment #9
helmo commentedThat would be [server:HTTP_REFERER] and [server:HTTP_USER_AGENT]
Comment #10
tremor commentedI have tried this from #6 but it doesn't seem to be working.. is there any reason why it's just returning nothing?
Comment #11
mitchtollerud commented#6 works for me in webform results. Thanks for the solution.
Comment #12
Yuri commented#6 is working fine! Thanks!
Comment #13
HitbyHi, I've made a custom module referer_token containing the code above with the functions renamed
function referer_token_token_info() {
and
function referer_token_tokens($type, $tokens, array $data = array(), array $options = array()) {
then placed [server:HTTP_REFERER] in the redirect field on the webform. When I complete the form though I'm just left on the form page. Will this code work with webform-7.x-4.16?
As an aside, my use case is using Webform Private File Gateway to forward links on a page to the webform to collect an email address. The user then receives an email with their download link and I'd like them to be redirected back to the page on which they clicked the download link.
Cheers!
Comment #14
kristindev commentedAnother up vote for #6
Comment #15
wlofgren commentedI've made a custom module that adds the referrer url to be able to use in Rules.
page_referrer.info
page_referrer.module
Comment #16
pmoz commentedJust in case anyone else stumbles upon this.
Add and enable the custom module that @helmo was kind enough to share in #6.
[submission:values:referring_page:nolabel] and hit save.
Now when you view the form you should see the referring page in the disabled text filed. Disabling the field instead of hiding it makes it a bit easier to troubleshoot in the future.
You'll need to go through both steps for every form that you want to apply it to.
Overall I agree that this should be a part of webform but at least there is a workaround.
Comment #17
cguidog commentedHi @pmoz,
I followed your instructions and I am halfway there.
My form is located in an url that looks like this: https://example.com/category/article
After adding the module this is what I'm getting: https://example.com/category/
So basically the article slug is not being included.
Any ideas what could be missing?
Thanks,
Comment #18
jamesfk commentedHi everyone,
Thanks, @helmo for the code, which worked perfectly.
We needed this functionality for a couple of clients, so made a quick module that might be easier for anyone else needing this:
https://www.drupal.org/project/referrer_token
All the best,
James