Answers.Body: <p>Have you tried using the <code>{{ craft.request.url }}</code> variable in your returnUrl setting?</p>
  
  <p>Also you should be able to format it like so:</p>
  
  <pre><code>returnUrl: craft.request.url ~ "?success"
  </code></pre>
  
  <p>More details about the craft.request model can be found here: <a href="https://craftcms.com/docs/templating/craft.request" rel="noreferrer">https://craftcms.com/docs/templating/craft.request</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-09T12:15:26.857Z
Answers.Text: In Craft 3+ this should be `craft.app.request.url` otherwise you'll get a deprecation error.
Answers.UserDisplayName: Tim Coysh
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-13T11:59:26.620Z
Answers.LastActivityDate: 2017-04-13T11:59:26.620Z
Answers.UserDisplayName: Matt Shearing
Body: <p>I'd like my form to return to the same page with a param ?success. </p>
  
  <p>The page slug is dynamic though so will change depending on what form you are on.</p>
  
  <p>/dynamic-url?success</p>
  
  <pre><code>{% set entrySlug = craft.request.lastSegment %}                         
  
  
                                      {{ craft.freeform.form("landingPage", {
                                          id: "form-landing",
                                          useRequiredAttribute: true,
                                          returnUrl: "{{ entrySlug }}?success"
                                      }).render() }}
  </code></pre>
  
  <p>Obviously if i just use <code>returnUrl: "?success"</code> it takes me back to the homepage.</p>
  
  <p>The idea of this is so I can trigger facebook events upon form completion, so open to any better approaches.</p>
  
  <p>Thanks</p>
  
Tags: <plugin-freeform><solspace><freeform>
Title: Freeform ReturnURL to same page
ThreadText: # Freeform ReturnURL to same page
  
  (Asked by: username_0 on 2017-04-13)
  
  I'd like my form to return to the same page with a param ?success.
  
  The page slug is dynamic though so will change depending on what form you are on.
  
  /dynamic-url?success
  
  ```
  {% set entrySlug = craft.request.lastSegment %}                         
  
                                      {{ craft.freeform.form("landingPage", {
                                          id: "form-landing",
                                          useRequiredAttribute: true,
                                          returnUrl: "{{ entrySlug }}?success"
                                      }).render() }}
  
  ```
  
  Obviously if i just use `returnUrl: "?success"` it takes me back to the homepage.
  
  The idea of this is so I can trigger facebook events upon form completion, so open to any better approaches.
  
  Thanks
  
  **Tags:** plugin-freeform, solspace, freeform
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-04-13. Score: 5 | Accepted answer
  
  Have you tried using the `{{ craft.request.url }}` variable in your returnUrl setting?
  
  Also you should be able to format it like so:
  
  ```
  returnUrl: craft.request.url ~ "?success"
  
  ```
  
  More details about the craft.request model can be found here: <https://craftcms.com/docs/templating/craft.request>
  
  > **Comments:**
  > **username_2**: In Craft 3+ this should be `craft.app.request.url` otherwise you'll get a deprecation error.  
  
  ---
  
  