Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Alternating two modules over a 48 hours period

Alternating two modules over a 48 hours period

Hi Stephen, I hope you are well.

I was wondering, I got 2 video module that I would like to show in cycle over a 48 hours period; 24 hours each.

I would like my user to see both video if they visit the site 2 times within 48 hours or more in order to secure conversion.

Any ideas?

Cheers,
Alex

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: Alternating two modules over a 48 hours period

so... could you do this by setting a 48 hour cookie when a user 1st visits and hits that page. The cookie would contain a timestamp 12 hours in the future. At that point you serve the 1st video module.

If the user returns to the page, you detect if the cookie is set. If so, and if the timestamp in the cookie is still in the future, you play the 1st video.

If the timestamp in the cookie has passed (i.e. it is between 12 and 24 hours since the cookie was 1st set), then you play the 2nd video.

Is that what you're after? (I'm not 100% sure). Perhaps this partial solution might prompt you on a better way to do it?

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: Alternating two modules over a 48 hours period

Hi Stephen, thank you for your quick reply.

What I'm after is a way for the user to see 2 different video on the same module position (frontpage); IF he happens to visit the site twice on 2 consecutive time that are more than 12 or 24 hours apart, whatever cookie is easier done.

Cheers,
Alex

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: Alternating two modules over a 48 hours period

ok, so the user hits the page.
- if no cookie found, then show 1st video and set cookie
- if cookie found and it's less than 12 hours old, still show 1st video
- if cookie found and it's more than 12 hours old, show the 2nd video.

So does the user have to wait with a gap of 12 hours or more before getting the 2nd video? Or can she be hitting the site continually for 12 hours, then at that time the 2nd video will start to play? You seem to be suggesting above that there needs to be a complete gap of 12 hours, suggesting the following:

- user hits page
- if no cookie found, then show 1st video and set cookie
- if cookie found and it's less than 12 hours old, still show 1st video, and refresh cookie
- if cookie found and it's more than 12 hours old, show the 2nd video.

So after the user has had the 2nd video served to her, what should happen the next time she hits the page? Back to 1st video, or stay on 2nd video for another 12 hours? You could make it so that the 2nd video shows for a further 12 hours, at which time the cookie is deleted, and it's back to the beginning again. Is that what you're after?

Complicated isn't it?!

Best regards,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: Alternating two modules over a 48 hours period

Ok Stephen, let's take a more logical avenue, without the 12 hour gap.

What about having two or more video. I want to be sure to track the user visualizing the 1st video before getting the 2nd (after getting the cookie from the 1st), then the 2nd before the 3rd (after getting the cookie from the 2nd, and so forth.

I use the JW player with allvideo plugin. Could we track and store the action of "playing the video" triggered by the user clicking, then store that in a cookie with an incremental variable?

-User come for the first time, video 1 is shown
  -Clicks on the video 1, cookie is stored
     - User revisit, cookie "video 1" is found,
         -Video 2 is shown
          -User clicks on video 2
          -Cookie is incremented to video 3

-User doesn't click
  -Video 1 is shown forever

Is that more simple?

Cheers,
Alex

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: Alternating two modules over a 48 hours period

Hi Alex,

yes we could definitely achieve that, providing you can work out how to set the cookie when the video is played or completed. It's possible to attach JS events to the buttons on the player, for playing the video. There are events for onPlay and onComplete, as well as others.

see http://www.longtailvideo.com/support/jw … ce/#Events

here's a sample of the JS required to set up the player, with space for an onPlay event:

<div id='container'>Loading the player ...</div>
<script type='text/javascript'>
jwplayer('container').setup({
  flashplayer: '/jwplayer/player.swf',
  file: '/uploads/video.mp4',
  height: 270,
  width: 480,
  events: {
    onPlay: function(event) {
      // set a cookie here?
    }
  }
});
</script>


So if you can work out the JS required to set a cookie (sorry I don't have that to hand) then you can use that in the example above, and that cookie can be detected in MetaMod.

So if the cookie after playing vid 1 is PlayedVideo=1, then you could do this in MetaMod:

if (@$_COOKIE['PlayedVideo'] == '1') return XXX; // module for video 2
if (@$_COOKIE['PlayedVideo'] == '2') return YYY; // module for video 3
if (@$_COOKIE['PlayedVideo'] == '3') return ZZZ; // module for video 4
// etc.


How does that look to you?
Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: Alternating two modules over a 48 hours period

Hi Stephen, sorry for the delay. This thread is applicable for my business model once again and I would like to follow through with it.

I found this way on setting up a cooking for the longtail player. This is a great example on how to "Autoplay only once". Setting up a cookie is off course necessary. To acheive this, they use this script:

<script>
  if(document.cookie.indexOf("jwplayerAutoStart") == -1) {
    document.cookie = "jwplayerAutoStart=1";
    jwplayer().play();
  }
</script>

I think it would be fairly easy to modify it in order to acheive the purpose of this thread.

Here is where I took this example:
http://www.longtailvideo.com/support/jw … -only-once

In my plugin directory for this player named "avreloaded" there is the following script file. I am not too sure which one to edit (see image).

http://s21.postimg.org/8dsnxsk6v/avreloaded.jpg

Any clues?

I hope you are well...
Cheers,
Alex

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: Alternating two modules over a 48 hours period

Sorry I don't have a lot of time to look at this - in the end I think this can be done purely with JS rather than having to involve MetaMod. (though you could use MetaMod as a container for outputting the JS, but the MetaMod itself wouldn't need any logic in it).

JS is not my strongest point and it's not really part of the MetaMod support deal smile but you know I always like to help if I can.

So my 1st stab at the JS required would be this:


<div id="myElement"></div>
<script>

// first a couple of functions to easily set and get cookie values:
function mysetCookie(c_name,value,exdays)
{
  var exdate=new Date();
  exdate.setDate(exdate.getDate() + exdays);
  var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
  document.cookie=c_name + "=" + c_value;
}

function mygetCookie(c_name)
{
  var c_value = document.cookie;
  var c_start = c_value.indexOf(" " + c_name + "=");
  if (c_start == -1) {
    c_start = c_value.indexOf(c_name + "=");
  }
  if (c_start == -1)  {
    c_value = null;
  }
  else {
    c_start = c_value.indexOf("=", c_start) + 1;
    var c_end = c_value.indexOf(";", c_start);
    if (c_end == -1) {
      c_end = c_value.length;
    }
    c_value = unescape(c_value.substring(c_start,c_end));
  }
  return c_value;
}

  var watched = mygetCookie("watched");
  if ( watched == '' or watched == null ) {
    jwplayer("myElement").setup({
      image: "/uploads/myPoster1.jpg",
      file: "/uploads/myVideo1.mp4",
      events: {
        onComplete: function(event) {
          mysetCookie('watched',1,365);
        }
      }
    });
  } else if (watched == 1) {
    jwplayer("myElement").setup({
      image: "/uploads/myPoster2.jpg",
      file: "/uploads/myVideo2.mp4",
      events: {
        onComplete: function(event) {
          mysetCookie('watched',2,365);
        }
      }
    });
  } else if (watched == 2) {
    jwplayer("myElement").setup({
      image: "/uploads/myPoster3.jpg",
      file: "/uploads/myVideo3.mp4",
      events: {
        onComplete: function(event) {
          mysetCookie('watched',3,365);
        }
      }
    });
  }

  // if you want to autoplay:
  jwplayer().play();

</script>


Variations:
1 - change the cookie duration from 365 days to a shorter time
2 - change 'onComplete' to 'onPlay' if you only need people to start each video, not necessarily complete it.

Now, I haven't tried this out, but it I hope it will set you in the right direction.

If you want to use that inside MetaMod as your delivery mechanism, you'll need to put ?> before the start of it, and <?php at the end of it because otherwise MetaMod expects PHP code.

Hope that helps,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5913
Dormant:
User Info:
 
Total Users:
10789
Newest User:
parus6
Members Online:
1
Guests Online:
250

Online: 
parus6

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked