Answers.Body: <p>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). </p>
  
  <p>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:</p>
  
  <pre><code>https://yourdomain.org/civicrm/contribute/transact?reset=1&id={contribution page id}</code></pre>
  
  <p>There's probably a way to convert that to a wordpress shortcode if you're smarter than I am about such things.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-22T21:42:21.467Z
Answers.Text: 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/`.
Answers.UserDisplayName: Martin_W
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-24T15:05:06.937Z
Answers.Text: 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.
Answers.UserDisplayName: Alan Dixon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-21T15:00:31.743Z
Answers.LastActivityDate: 2020-02-21T15:00:31.743Z
Answers.UserDisplayName: Alan Dixon
Body: <p>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.)</p>
  
  <p>I'm on WordPress 5.23 and CiviCRM 5.13.</p>
  
  <p>I've added the <code>{debug}</code> token to the HTML email template to inspect the available variables and didn't find anything quite suitable. There is a variable called <code>$printerFriendly</code> 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?</p>
  
  <p>(<em>Side note in case it helps someone: if you include <code>{debug}</code> in <strong>both</strong> 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!</em>)</p>
  
Tags: <civicontribute><email><receipts><smarty><donations>
Title: How to include source page URL in donation page email receipt?
ThreadText: # How to include source page URL in donation page email receipt?
  
  (Asked by: username_0 on 2020-02-21)
  
  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!*)
  
  **Tags:** civicontribute, email, receipts, smarty, donations
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-02-21. Score: 1 | Accepted answer
  
  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.
  
  > **Comments:**
  > **username_0**: username_1, 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/`.  
  > **username_1**: 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.  
  
  ---
  
  