Home > Technical & Creative Skills > Programming, Servers & Scripts

Plutus Toolkit - Binom Cost Synchronizer (16)


11-28-2020 08:39 PM #1 plutus (Member)
Plutus Toolkit - Binom Cost Synchronizer

December is approaching so it's time for another contribution.

I’d like to present you Binom Cost Synchronizer.

Binom Cost Synchronizer is a python script that synchronizes costs in Binom using traffic sources APIs.

List of supported traffic sources:
- PropellerAds

How to set it up on your server?

There is an install script to make everything less complicated for non-technical users that have to be executed. I’m also leaving short guidelines for more technical people here.

For technical people:



For non-technical people:
Log in to your Hetzner panel and select your project.








Navigate to rescue:



Click on Reset Root Password:









Copy that password (CTRL + C)


Open up console window:





Type in root as a login:




As a password use the one that you just reset - paste it here





Paste this code into the console:

Code:
wget -O - https://raw.githubusercontent.com/piotrusin/binom-cost-synchronizer/main/install.sh | bash
This console is not pasting everything correctly and text needs to be fixed in two places:




The first thing to fix is replacing the semicolon ; with a colon :
The second thing to fix is replacing backslash \ with pipe |

You end up with this:



Hit enter. You should see ASCII art dollar sign that says that installation has started.

In the end, you will be asked a few questions about your:
Binom Domain - the domain that you are using to host your Binom WITH https:// at the start. Preferably just copy it from your browser:



Your domain is in the red rectangle part and that’s the thing that needs to be pasted.

Binom API Key - can be found in Binom settings, here:


You just need to paste a part that is in the red rectangle, without &api_key= prefix

PropellerAds API Key - can be found in PropellerAds settings



Create token and copy it:



Timezone - this is a number that represents UTC timezone that will be used when updating costs - for example, if you have your tracker set up on UTC+1 you have to input 1 there, for UTC-2 you have to input -2, etc.

That’s it. You should see a message that the installation finished. Your costs will be now updated daily based on PropellerAds API.

How does it work?

It executes python script daily, using cronjob on your server.

This python script is fetching your Binom Campaigns and matches it with traffic source campaigns based on the campaign URL.

Next, it fetches the cost of matched campaigns for the previous day using the configured timezone.

Lastly, it updates the cost of the Binom campaign(s) for the previous day using the configured timezone.

It supports using the same Binom campaign URL in multiple traffic source campaigns - cost is just adding itself up for the matched campaigns to the total cost of the given Binom campaign.

Uninstalling

The script is solely based on the cronjob so removing it from that place disables it completely.

This can be achieved by running crontab -e command as user that installed it, removing a line that executes it, and saving changes.

All the source files are located in ~/binom-cost-synchronizer and can be removed afterward.

Conclusion

Since this is a far more delicate topic than Offer URL Generator and it requires API keys configuration for both Binom and Traffic Sources so I'm making source code public.

You can find the GitHub repository, with the README.MD that explains how to install it on your server over here:
https://github.com/piotrusin/binom-cost-synchronizer

So far only PropellerAds is supported but I've prepared a codebase in a way that is flexible to add new Traffic Sources later on if someone would need them.

Setting this up will require little techy knowledge of how to connect to your server using ssh and execute the install script, you can also follow up on Hetzner guidelines that I pointed out above.

There are two log files that are created in the script directory:
cron.log - saves outputs of the executed python script
update.log - logs which Binom campaign was updated and what is the new cost

I've been testing it since the last week and it is working as expected but I'm not running hundreds of campaigns so I was unable to test all possible cases in a larger campaign volume.

Hope it helps,
plutus


11-28-2020 11:56 PM #2 vortex (Senior Moderator)

Holy shit this is a TREMENDOUS contribution plutus!

This solves one of the most annoying shortcomings in tracker stats!

You should approach the tracker companies and sell them your solution.

I will link to this thread in the 40-day tutorial!

Thank you so much for this and other contributions!



Amy


11-29-2020 08:05 AM #3 jeremie (Moderator)

Great script @plutus

Just wanted to let you know that matching based on campaign URL will not work for people using Direct Tracking (what they call LP Pixel in Binom).

In this case, the TS URL contains the pre-lander URL and the campaign is tracked through a JS pixel on page. The pre-lander may contain the campaign key passed as a parameter (see section "One LP Pixel for multiple campaigns" in the page below) and in this case you can find a way to match. Yet, affiliate might also decides to hardcode the campaign key on page. In this case, there is little you can do.

https://docs.binom.org/lp-pixel.php

In config, you could have a boolean IsDirectTracking, and in this case a KeyParameter that will indicate which GET parameter to read the Binom key from, inside the URL.


11-29-2020 08:27 AM #4 erikgyepes (Moderator)

Quote Originally Posted by jeremie View Post
Great script @plutus

Just wanted to let you know that matching based on campaign URL will not work for people using Direct Tracking (what they call LP Pixel in Binom).
Same is true if the URL is customized, I see you are looking for "%s/click.php?key=%s" and that would break in this case. So maybe add a configuration parameter to be able to set it.

Otherwise cool script!


11-29-2020 08:50 AM #5 plutus (Member)

Quote Originally Posted by vortex View Post
You should approach the tracker companies and sell them your solution.
You think that they would be interested in service like this one?

I coded this because it was annoying for me to see false-positive costs and profits for SmartCPM campaigns.

Quote Originally Posted by jeremie View Post
Great script @plutus

Just wanted to let you know that matching based on campaign URL will not work for people using Direct Tracking (what they call LP Pixel in Binom).

In this case, the TS URL contains the pre-lander URL and the campaign is tracked through a JS pixel on page. The pre-lander may contain the campaign key passed as a parameter (see section "One LP Pixel for multiple campaigns" in the page below) and in this case you can find a way to match. Yet, affiliate might also decides to hardcode the campaign key on page. In this case, there is little you can do.

https://docs.binom.org/lp-pixel.php

In config, you could have a boolean IsDirectTracking, and in this case a KeyParameter that will indicate which GET parameter to read the Binom key from, inside the URL.
Quote Originally Posted by erikgyepes View Post
Same is true if the URL is customized, I see you are looking for "%s/click.php?key=%s" and that would break in this case. So maybe add a configuration parameter to be able to set it.

Otherwise cool script!
Thank you both for your insightful review.

You both are right, campaign matcher is pretty stupid right now.

I added separate issues for both cases and will update script in the next week.


11-29-2020 08:59 AM #6 erikgyepes (Moderator)

Quote Originally Posted by plutus View Post
You both are right, campaign matcher is pretty stupid right now.
It's not stupid, I learned the hard way when doing my own scripts ... there are always those minor things that can break it (worst is when some traffic sources change their API output without any notification)


11-29-2020 09:09 AM #7 plutus (Member)

Quote Originally Posted by erikgyepes View Post
It's not stupid, I learned the hard way when doing my own scripts ... there are always those minor things that can break it (worst is when some traffic sources change their API output without any notification)
Haha, right.

I can imagine pretty clearly PropellerAds switching to V6 without any prior notice, it must've been annoying for you.

I see no docs in PropellerAds API swagger for the previous four versions so they probably just disabled it completely without any backward compatible support.


11-29-2020 09:48 AM #8 jeremie (Moderator)

Quote Originally Posted by plutus View Post
You think that they would be interested in service like this one?
I personally don't think so. At least not with a simple integration for one single function. Don't get me wrong, i am not minimizing the work.

But those interested in integrating do it themselves. See Voluum for example:
https://doc.Voluum.com/en/propellerads_integration.html

And for the rest, you can rely on tools like theoptimizer to get accurate campaign cost, which is anyway only a part of it. Clickloss is another topic that you won't see at campaign level.

This said, I would still show them. As you like coding, maybe you can barter free account/reduced tracker pricing for some coding.

Quote Originally Posted by plutus View Post
You both are right, campaign matcher is pretty stupid right now.
Don't be hard on yourself. You did a great job coding a tool for your setup. Now the community can open more doors to give you a bigger picture. That is what is so great with open source.


11-29-2020 11:02 AM #9 plutus (Member)

Quote Originally Posted by jeremie View Post
I personally don't think so. At least not with a simple integration for one single function. Don't get me wrong, i am not minimizing the work.

But those interested in integrating do it themselves. See Voluum for example:
https://doc.Voluum.com/en/propellerads_integration.html

And for the rest, you can rely on tools like theoptimizer to get accurate campaign cost, which is anyway only a part of it. Clickloss is another topic that you won't see at campaign level.

This said, I would still show them. As you like coding, maybe you can barter free account/reduced tracker pricing for some coding.
I realize that this is far from being complete product, more like a blueprint.

SInce I already decided to leave it up open sourced I'll just leave it as it is.

You got me thinking about a way I can barter my coding skills for a free tracker, this would be neat.

Quote Originally Posted by erikgyepes View Post
It's not stupid
Quote Originally Posted by jeremie View Post
Don't be hard on yourself.
I think that I used the wrong word here and I was misunderstood by both of you.

By stupid I meant that it is just simple one-line if statement that check if one url is contained in the other.

Quote Originally Posted by jeremie View Post
Now the community can open more doors to give you a bigger picture. That is what is so great with open source.
This is indeed nice.

I'm myself moving out from the SmartCPM-type of paid traffic and leaving it open sourced is the best I can do for the community in case someone would want to extend this later on for himself/herself.


11-29-2020 08:07 PM #10 matuloo (Legendary Moderator)

Very nice plutus, I really love your contributions!!!


11-29-2020 10:09 PM #11 vortex (Senior Moderator)

Having all these members contribute to make this a better tool - is nothing short of AWESOME!

This is what STM is about: Working together to figure things out.

I applaud you guys!



Amy


Sent from my iPhone using STM Forums


11-30-2020 04:38 AM #12 affpayinggao (Veteran Member)

Very nice script. thanks for sharing


11-30-2020 11:24 AM #13 matuloo (Legendary Moderator)

I realize that this is far from being complete product, more like a blueprint.

SInce I already decided to leave it up open sourced I'll just leave it as it is.

You got me thinking about a way I can barter my coding skills for a free tracker, this would be neat.
@plutus how about a bit of motivation? I believe that when someone decides to take the extra mile and actually dedicate their time to building something useful for all of us here, without expecting any kind of compensation... such activity should be rewarded! So I thought you might enjoy a month (or a few ) of free STM access as a gift of appreciation from us, how does that sound? Amy will get in touch with you to arrange it

Keep the great stuff coming!


11-30-2020 08:52 PM #14 plutus (Member)

Quote Originally Posted by matuloo View Post
@plutus how about a bit of motivation? I believe that when someone decides to take the extra mile and actually dedicate their time to building something useful for all of us here, without expecting any kind of compensation... such activity should be rewarded! So I thought you might enjoy a month (or a few ) of free STM access as a gift of appreciation from us, how does that sound? Amy will get in touch with you to arrange it
Wow. This is so generous of you, thank you thousand times. Amy already did contact me about it. I'm flattered to receive such a reward.

Quote Originally Posted by matuloo View Post
Keep the great stuff coming!
Worry not, I'm far for resting on this laurels. I'm already planning another contributions, so as always - stay tuned.


12-15-2020 08:37 PM #15 twinaxe (Senior Moderator)

Great share but why only update the costs once a day?

Isn't it possible to add an option to choose between several update intervals?


12-16-2020 05:31 AM #16 plutus (Member)

Quote Originally Posted by twinaxe View Post
Great share but why only update the costs once a day?

Isn't it possible to add an option to choose between several update intervals?
Great question twinaxe.

It runs in cronjob which is VERY flexible if it comes to execution intervals.

Default is once daily, this can be easily adjusted (by changing one line in configuration) to once in a 5 minutes or so.

There is some awersion or bias related to "gurus" in the marketing world but there is one GURU that is in that case irreplecable.

And his name is: https://crontab.guru/

You can test your cronjob expression there and just edit the configuration on your server when finding perfect match for you by executing:

Code:
crontab -e
and replacing previous expression (at the beginning of the line, rest must remain the same).

If you are interested in using my toolkit in this exact way, hit me up on PM we will figure it out.

plutus


Home > Technical & Creative Skills > Programming, Servers & Scripts