Guys, I need help for setup time based ads on a website | Coding experts

RichKIDLK

BANNED
Joined
Aug 30, 2020
Messages
1,200
Reaction score
1,157
Hi it's me again,

I need to setup an ads on my website like this.

The ads should appear in first 30 minutes only when user arrived and browsing my website. I'll notice this to my visitors with notice for their convenience.

How do I setup this? Just need to show ads in first 30 min only (pop under, pop or any kind of ads). After 30 min all ads need to stop showing for that user. But in the first 30 min I need to show ad on every possible movement (like scrolling, page browsing)

How do i set up this. Any help friends..
 
First: gather all the JS files from the ads

Second: depending on how you want to track your users, but lets consider a simple solution for your any kind of visits that just stays in your site for 30 minutes. Considering that you will need to track the session start regardless of the pages navigates, you will need to set up a cookie with the session start time. With PHP you can do this with setcookie. There are other methods of browser storage apart from cookies, this is just one example.

Third: Removing ads could be tricky: two ideas:
a) With PHP you can just compare the cookie with the current time, if >30 minutes, then remove all the ads scripts from loading. For example, with wordpress you can just simple dequeue scripts.
b) With Javascript on the fly, you can also set a timer everytime the user loads a page by know the left time by substracting the current time from the cookie time. If that time passes without reloading or switching the page, you can just remove the appended scripts with removeChild method

It can go more complex, if you are willing to do this based for example, on the total time spent in your site by your users but here is a basic idea of what you need.

I feel this topic fits better here by the way: https://www.blackhatworld.com/forums/scripting.59/
 
First: gather all the JS files from the ads

Second: depending on how you want to track your users, but lets consider a simple solution for your any kind of visits that just stays in your site for 30 minutes. Considering that you will need to track the session start regardless of the pages navigates, you will need to set up a cookie with the session start time. With PHP you can do this with https://www.php.net/manual/es/function.setcookie.php. There are other methods of browser storage apart from cookies, this is just one example.

Third: Removing ads could be tricky: two ideas:
a) With PHP you can just compare the cookie with the current time, if >30 minutes, then remove all the ads scripts from loading. For example, with wordpress you can just simple dequeue scripts.
b) With Javascript on the fly, you can also set a timer everytime the user loads a page by know the left time by substracting the current time from the cookie time. If that time passes without reloading or switching the page, you can just remove the appended scripts with https://developer.mozilla.org/es/docs/Web/API/Node/removeChildmethod

It can go more complex, if you are willing to do this based for example, on the total time spent in your site by your users but here is a basic idea of what you need.

I feel this topic fits better here by the way: https://www.blackhatworld.com/forums/scripting.59/

wow. Thank you so much for this explanation. Honestly thank you for this answer again. I'll check this and follow this guides as well. If I got any issues in the middle I'll reply you dear @SirLouen
 
Back
Top