Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
Redirect user on page on click link from google results to some URL

I want to do some logic if user click my website in google results and go to my website then when he click one of links on website then he is redirect to some url (eg https://example.com)

I tried this way:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> 
<script>

    var ref = document.referrer;
    document.write('document.referrer: ' + ref)

    $("a").click(function() { 
            
        if (ref === "https://www.google.com/" || ref === "https://www.google.pl/") {
            window.location.href = "https://example.com";
        }
    });

</script>

but this version redirect to normal link target not to example.com. How can I improve this?

Now this works only when my link on website have target="_blank" then it redirects to example.com in main window and in new window redirect to website link location.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!