When my CiviContribute donation pages send out email receipts, I would like the emails to include the URL of the source page (i.e., the WordPress page that contains the shortcode of the CiviCRM donation page). Is there a Smarty variable that has that source (or "referrer") page URL? Or is there another way to accomplish this? (Seems like this would be a good variable to have.)

I'm on WordPress 5.23 and CiviCRM 5.13.

I've added the {debug} token to the HTML email template to inspect the available variables and didn't find anything quite suitable. There is a variable called $printerFriendly that seems to have the page URL but with extra query string parameters. Is there a Smarty feature to discard the query string and retain just the page URL?

(Side note in case it helps someone: if you include {debug} in both the HTML email template and the plain text email template, the contribution page will fail with a "too many redirects" error, and the contribution does not get recorded!)

1 Answer 1


I think the short answer must be "no". Once the client is on a CiviCRM page, there are usually a few clicks before you get to the email receipting code, so at that point, there wouldn't be any record of the referrer (unless you have some code that is saving it).

There should be a way to construct at least one version of a contribution page url, if you have that in your smarty variabloes, using the contribution page id, like:

https://yourdomain.org/civicrm/contribute/transact?reset=1&id={contribution page id}

There's probably a way to convert that to a wordpress shortcode if you're smarter than I am about such things.

  • Alan, thanks... In my case, the Civi Donation Page is configured to process the payment immediately, without a confirmation page. ("Use a confirmation page?" is unchecked on "Title" tab of the Donation Page configuration.) But I understand your point. In the general case, one could not guarantee the variable contained the original WordPress page URL. Still, a "referrer" variable would be a nice tool for the toolbox... In my case, the donation page URL is fairly "clean" and SEO friendly, simlar to: https://mynonprofit.org/donate/special-project-fund/.
    – Martin_W
    Feb 22, 2020 at 21:42
  • I believe you could also accomplish your goal using a fairly simple piece of javascript built into a civicrm extension. Javascript can read and write cookies, so you'd just want to save your url to a sessions cookie when you first arrive (i.e. before it has a value) and then read it when you need it.
    – Alan Dixon
    Feb 24, 2020 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.