How to prevent direct traffic to and sharing of thank you pages and PDF downloads? | Community
Skip to main content
November 11, 2014
Solved

How to prevent direct traffic to and sharing of thank you pages and PDF downloads?

  • November 11, 2014
  • 4 replies
  • 1711 views
I searched the community and found this article, but the answer doesn't seem clear to me. Possibly bc I'm a noob!

I've read that I can add some javascript code to redirect back to the landing page, but I'll have manually change it everytime.

Is there a better way? And if not, what's the code? :)

 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by
You could redirect if it is the incorrect referrer page. In other words, they would have to come from a certain page, or it would redirect to page where they would to fill out a form to get content. I created this example for you. Just add it before closing </body> tag on the page. 

<script>
window.onload = function() {
  if (document.referrer !== "CHANGE THIS TO THE PAGE THAT LINKS TO PDF") {
    document.location.href = "CHANGE THIS TO THE PAGE THAT LINKS TO PDF";
  };
 };
</script>

So it should look like this:

<script>
window.onload = function() {
  if (document.referrer !== "http://example.com/landingpage") {
    document.location.href = "http://example.com/landingpage";
  };
 };
</script>

4 replies

Accepted solution
November 11, 2014
You could redirect if it is the incorrect referrer page. In other words, they would have to come from a certain page, or it would redirect to page where they would to fill out a form to get content. I created this example for you. Just add it before closing </body> tag on the page. 

<script>
window.onload = function() {
  if (document.referrer !== "CHANGE THIS TO THE PAGE THAT LINKS TO PDF") {
    document.location.href = "CHANGE THIS TO THE PAGE THAT LINKS TO PDF";
  };
 };
</script>

So it should look like this:

<script>
window.onload = function() {
  if (document.referrer !== "http://example.com/landingpage") {
    document.location.href = "http://example.com/landingpage";
  };
 };
</script>
Matt_Stone2
Level 9
November 11, 2014
An alternative is to do away with thank you pages/download pages and deliver everything via email. There's a lot of discussion on this, but it does ensure that you're getting a clean email (if they really want the asset).

Either way, you're going to fight a losing battle because if people want the PDF that badly, someone else could always just save it and deliver it to them that way.
November 12, 2014
Murtza, I'll give that a try. Matt - I guess you're right. I can just show the TY page and say the email will have a link to the PDF.

I'll have to think about that.

Thanks both!
November 12, 2014
Hey all I tried this but now the ty page redirects to the dl page even after I filled out the form. I want the code so that it doesn't do it for ppl who fill out form, but it redirects to those who somehow bypassed the form.