• Resolved Anonymous User 15141300

    (@anonymized-15141300)


    Is it possible to redirect from the Source URL to Multiple Target URLs based on percentages? (either via standard functionality or hooks)

    For example, let’s say that I have my Source URL: https://mydomain.com/redir-page/

    And I want 50% of the time to redirect the visitor to: https://externaldomain.com/final-page/ and 50% of the time to redirect the visitor to: https://thirdpartydomain.com/final-page/

    Kind of like a split testing of redirects.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author John Godley

    (@johnny5)

    There are several hooks you could probably use to achieve this:

    https://redirection.me/developer/wordpress-hooks/

    Thread Starter Anonymous User 15141300

    (@anonymized-15141300)

    @johnny5 can you please point me to the right direction? on this one I am lost about which action / filter to use.

    Plugin Author John Godley

    (@johnny5)

    redirection_url_target for example.

    Thread Starter Anonymous User 15141300

    (@anonymized-15141300)

    I see that filter returns a URL (string). How could this be implemented code-wise? I was thinking about having 2 or more fields in the “Target URL” field in the plugin with percentages on each.

    My understanding is that with this option Target URL 1 will be configured in the Plugin, while the other Target URL 2 will be hard-coded in the function, which is far from ideal. Is this how it would work?

    Plugin Author John Godley

    (@johnny5)

    I see that filter returns a URL (string). How could this be implemented code-wise? I was thinking about having 2 or more fields in the “Target URL” field in the plugin with percentages on each.

    My understanding is that with this option Target URL 1 will be configured in the Plugin, while the other Target URL 2 will be hard-coded in the function, which is far from ideal. Is this how it would work?

    No, that would require major changes to the plugin. It seems to me that just returning a different URL in the hook, and you perform whatever random choice you need inside your code is the only reasonable solution.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘From Source URL to Multiple Target URLs (Percentages)’ is closed to new replies.