Home > Tracking Campaigns > FunnelFlux

Redirect based on offer's page content (15)


04-10-2018 10:02 AM #1 vitavee ()
Redirect based on offer's page content

I got an interesting question today via PM, and preferred to post this thread as it may help others.

Scenario:

You're promoting an offer that has a daily cap, network wide. (for account wide daily caps, you can use the ready-made cap condition in FunnelFlux). When the offer reaches its maximum cap, the network automatically redirects to another offer that you can't or don't want to promote for a reason or another.

Is it possible to automatically redirect to an offer of your choice when the network switches to that other offer?

Answer: of course you can do that with FunnelFlux and its PHP Nodes

The solution is to use a PHP Node before redirecting to offer 1, to check its page content. If some words are there on the page, then all is good and you can link to it. Otherwise, branch to another offer of your choice!

Here's how the funnel looks like:



If some specific content is found on the page, redirect to offer 1. Otherwise redirect to offer 2.

Let's look at the PHP Node itself:

Code:
<?php

$url = "http://your-affiliate-link";
$contentThatMustBeHere = "the page content to check for";

$output = file_get_contents( $url );
if( strpos($output, $contentThatMustBeHere) !== false ) {    
    // content is here... follow route #1    
    return 1;
}

// content is NOT on target page, follow route #2
return 2;

?>
That makes this PHP Node check for the content of one specific offer page. It's not very flexible if you want to use that in different funnels, for different offers.

To make it more flexible, you may want to use the custom tokens feature in your funnels.

First open the advanced settings panel:



Enter those 2 custom tokens:



Then edit the PHP Node code to use these custom tokens instead of fixed values:

Code:
<?php

$url = "[[content-checker-url]]";
$contentThatMustBeHere = "[[content-checker-body]]";

$output = file_get_contents( $url );
if( strpos($output, $contentThatMustBeHere) !== false ) {    
    // content is here... follow route #1    
    return 1;
}

// content is NOT on target page, follow route #2
return 2;

?>
You can now use this same PHP Node in different funnels, for different offers.

Bonus: If you want to send yourself an email alert whenever the content is not found anymore on the page, you can add this in the PHP Node, just before the last "return 2;" (in FunnelFlux versions 1.6117 and above)

Code:
require_once 'PHPNodeHelpers.php';

PHPNodeHelpers::sendMail( [
	'to' => 'you@you.com',
	'email-subject' => 'Open this now',
	'email-body' => 'The html email content',
	'smtp-configuration' => [
	    'server' => 'your-smtp.server.com',
	    'port' => 'port number',
	    'secure' => 'ssl',    // this can be '', 'ssl' or 'tsl'
	    'username' => 'username to smtp service',
	    'password' => 'password to smtp service',
	    'from-name' => 'Me',
	    'from-email' => 'me@me.com',
	]
] );


04-10-2018 11:27 AM #2 bbrock32 (Administrator)

Wow!

No other tracker out there gives you this amount of flexibility.

If you remove the technical hurdles with the managed version, I doubt any other tracker out there can match the features.


04-10-2018 11:55 AM #3 xxf8xx (Member)

Will this work even for carrier offers? I believe because you are checking the offer page from your server it might not grab the right page. I think I was trying to do something with this a while back but had no way of getting the right page since the requests came from my server and not the user's IP.


04-10-2018 11:57 AM #4 bbrock32 (Administrator)

Quote Originally Posted by xxf8xx View Post
Will this work even for carrier offers? I believe because you are checking the offer page from your server it might not grab the right page. I think I was trying to do something with this a while back but had no way of getting the right page since the requests came from my server and not the user's IP.
Yep you are right, if they have a carrier redirection in place there is no way.

The only possible solution is to ask the network what parameter to pass so it shows the real page.

Usually they have a test parameter like test=true or preview=1 or similar.


04-10-2018 12:48 PM #5 vitavee ()

Quote Originally Posted by xxf8xx View Post
Will this work even for carrier offers? I believe because you are checking the offer page from your server it might not grab the right page. I think I was trying to do something with this a while back but had no way of getting the right page since the requests came from my server and not the user's IP.
Yes you can. It requires a little bit more work but basically you would use curl instead of get_file_contents and configure it to go through a proxied VPN.

Full details here:

http://www.georgiecasey.com/2013/07/...-a-curl-proxy/


04-10-2018 03:26 PM #6 mihalis09 (Member)

man that's sick, I recently had this problem too and had to reduce sending traffic to the offer lest it hits the cap overnite


04-10-2018 04:04 PM #7 quantum27 (Member)

That's an interesting technique. So on the network side, they would register 2 clicks?

How much extra delay would this add to the flow?

I was thinking about this problem a couple months back. Was considering a 30min polling system, where it checks every 30mins. Rather than check every click to offer.


04-10-2018 04:17 PM #8 zeno (Administrator)

Vitavee, lets say you are using landers and not direct linking.

Would you be able to pass traffic through a PHP node that is non-blocking, i.e. it does not wait for the page to load for the text check, but does this in the background and sets some parameter that can then be used on lander clickthrough?

I was thinking you could pass a parameter into the accumulated URL buffer to then access later.

E.g. Traffic > PHP Node 1 (does check, but routes traffic immediately) > some lander > PHP Node 2 (checks output PHP node 1 has determined, routes accordingly) > offers.


04-11-2018 10:08 AM #9 vitavee ()

Quote Originally Posted by quantum27 View Post
How much extra delay would this add to the flow?

I was thinking about this problem a couple months back. Was considering a 30min polling system, where it checks every 30mins. Rather than check every click to offer.
That will likely half the redirect speed, as it has to load the whole page. You can easily add a delay between checks by using FunnelFlux's internal caching system. For that you would wrap the code above with this:

Code:
<?php

$SECONDS_BETWEEN_CHECKS = 60 * 30;

$cacheKey = '{node-id}-content-checker-time';
$lastCheckTimestamp = Cache::quickGet( $cacheKey );
if( $lastCheckTimestamp === null || ($lastCheckTimestamp + $SECONDS_BETWEEN_CHECKS) < time() )
{
    Cache::quickSet( $cacheKey, time() );

     // INSERT INITIAL CODE HERE
}

?>
Quote Originally Posted by zeno
Vitavee, lets say you are using landers and not direct linking.

Would you be able to pass traffic through a PHP node that is non-blocking, i.e. it does not wait for the page to load for the text check, but does this in the background and sets some parameter that can then be used on lander clickthrough?

I was thinking you could pass a parameter into the accumulated URL buffer to then access later.

E.g. Traffic > PHP Node 1 (does check, but routes traffic immediately) > some lander > PHP Node 2 (checks output PHP node 1 has determined, routes accordingly) > offers.
Good idea, certainly possible but requires a bit more code to queue/process the content check requests.


04-11-2018 07:20 PM #10 heavyt (Senior Member)

I'm glad people are liking this Good tutorial @vitavee


04-24-2018 03:25 PM #11 mihalis09 (Member)

Vitavee, on sort of the same idea, is it possible to have the tracker allocate 100% of the traffic for that day, if you split test for instance 2 or 3 offers on a rotator and one of them starts strong for the day?

I have observed on some days one offer is doing well, others the other one. Can we automate traffic allocation if a rule like one of the offer's CR's exceeds x% is satisfied?


04-25-2018 11:48 AM #12 mindfume (AMC Alumnus)

^ you could read stats through API and then automatically allocate traffic using whatever algo e.g. Thompson Sampling would be easy to implement

I played with that idea in the past but got stuck due to this bug:
https://portal.productboard.com/funn...e=portal_share


04-25-2018 07:15 PM #13 vitavee ()

I'm preparing a tutorial for you guys, on how to do that. Should be ready soon


04-25-2018 07:50 PM #14 vitavee ()

Here you go:

https://stmforum.com/forum/showthrea...-on-Offers-EPV


04-26-2018 10:14 AM #15 mindfume (AMC Alumnus)

darn it Vitavee :-)


Home > Tracking Campaigns > FunnelFlux