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.

 

Using JomGenius to retreive valuable information on a submission form

Using JomGenius to retreive valuable information on a submission form

Hi Stephen,

I am using RsFormPro! to get new customers. When a form is submitted by a user it represent a conversion. I receive the input of the user in my email box. I can add php custom coding in RsFormPro! to retrieve additional data in that same email.

It would be extremely valuable for my strategy with metatemplate to retrieve data such as:

JomGenius wrote:


1.Which template was active when the form was submitted
2.What time was it in Quebec city/Canada when the user submitted the form (inTimeSpan or else)
3.From which link the user entered the site before submitting the form, and translate that link to an expression like "Article name, Organic source, CPC+Campaign source, Referral source, Direct link" (can it retrieve data from GA??)
4.check browsertype
5.check menutype

In your JomGenius section/about you wrote that:

Jomgenius wrote:

Using MetaMod and MetaTemplate (+ Pro versions), you can change which modules and/or templates will appear on any given Joomla! page, using information from JomGenius.

Would it be possible to use JomGenius to automatically change the right template according to "accumulated data analytic" from the inTimeSpan check or "link Source" check to get the best probable setting for conversion?

I think those 5 points would be very valuable to retrieve.

Cheers,
Alex

Edited By: atherrien
15-Feb-11 19:35:19

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

Re: Using JomGenius to retreive valuable information on a submission form

Wow, this is getting complex and a bit exciting!

Ok, let me get this right:

When someone converts (uses RSForm) you want to make a note of their original referrer, the time, the template they are on, the browsertype, and the actual page they were on when they filled out the form.

Correct?

Then once you have that information, what do you want to do with it?

- send it to Google Analytics?
- cookie the information for that user, so that when they return you'll automatically give them the same template again?
- accumulate that information so that as time goes by you can detect patterns of best conversion, and use these to automatically set the "best" template for people depending on these factors (time/referrer probably)?

In answer to your question about retrieving info from GA -- I'm not 100% sure, but I doubt that you can retrieve past history for that visitor.
However, it wouldn't be too hard to store the original referrer string into the visitor's session so you could retrieve that later (i.e. in RSForm). You'd just need to get the referrer string, ensure it wasn't in internal link on your own site, then if it was from outside, store it in the session. I'd make that the 1st rule in the MetaTemplate rule chain.

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
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Using JomGenius to retreive valuable information on a submission form

metamodguy wrote:

Ok, let me get this right:

When someone converts (uses RSForm) you want to make a note of their original referrer, the time, the template they are on, the browsertype, and the actual page they were on when they filled out the form

Yes that's correct. But I am still not sure of the best data to collect in order to decipher patterns in the conversion process. I really want to get the full potential of your components as much as possible. I think this would be a good start, but if you feel something more should be added I will gladly try it.

metamodguy wrote:

Then once you have that information, what do you want to do with it?

- send it to Google Analytics?

Yes, I think this is a must, as long as we are not constrained by the number of variable we can send to GA for data segmentation.

metamodguy wrote:


- cookie the information for that user, so that when they return you'll automatically give them the same template again?

Definitely. What converts for a user should stay on.

metamodguy wrote:

- accumulate that information so that as time goes by you can detect patterns of best conversion, and use these to automatically set the "best" template for people depending on these factors (time/referrer probably)?

Yes, that's the hard part isn't? I think you wrote JomGenius+metacomponents for that purpose. Can it be extended to other brilliant application like this example?

metamodguy wrote:

In answer to your question about retrieving info from GA -- I'm not 100% sure, but I doubt that you can retrieve past history for that visitor.

Right, I doubt it's possible without a GA external data segmentation application. I know there is such commercial application out there that offers new solutions for data segmentation. I will research on that the more and more we get into this topic.

metamodguy wrote:

However, it wouldn't be too hard to store the original referrer string into the visitor's session so you could retrieve that later (i.e. in RSForm).

I think you definitely see me coming; Can we store patterns as a whole and retrieve an answer that triggers the best possible template for new user ?

I think that is a good start, let's just focus on the use of templates for now. I can't think of anything to do with metamod for now to increase my conversion rates.

Cheers,
Alex

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

Re: Using JomGenius to retreive valuable information on a submission form

Ok, here are some basic steps:

1 - in the 1st MTP rule, you need to grab the referrer URL, and store it in the session if it's NOT a link from the current server. That way, if you get a conversion later in the session you'll know what the referrer was.

2 - in RSForm, when the conversion is made, retrieve the referrer from the session. Retrieve the current template name, also the time, current page and browser type. Use this information to create an ID string e.g. "referrer.com/page/here|2011-02-15 15:43:12|template_name|http://mysite.com/page_name". Put this string into a PHP constant, so you can retrieve it in the template.

3 - also in RSForm at this time, put an id number for the current template into a cookie for the user.

4 - in the template, at the point where you are setting custom GA variables, check for the existence of the ID string. If it's found, then add another custom variable with that string in it, so GA gets notified.

5 - back in MetaTemplate Pro, make the 2nd rule. In this rule, detect the permanent cookie that holds the id number for the template. If found, immediately set that template. You may or may not wish to allow the user to override this. If so, you might need to alter the order of the rules so that the rules that allow overriding come before this one.


What all this does is to make the system (i) notify GA of quite a lot of relevant information once a conversion is made, and (ii) remembers the template that a person was on at the time of conversion, and sets that template for them when they come back next time.

Hopefully you'll see some patterns emerging in the info in GA that might guide you as to which templates / times of day / pages produce the best conversions, and you might want to change your default template etc based on that information.


Before I write any code for this, please tell me if we're heading in the right direction?


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
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Using JomGenius to retreive valuable information on a submission form

Everthing seems correct. The thing that's missing is the echo of that information in understandable terms in the alert email when the form is submited to the admin email box.

I will collect and do some data segmentation within GA or a third party GA extension and look out for patterns.

I will keep you updated on that.

It's confirmed.
Cheers

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

Re: Using JomGenius to retreive valuable information on a submission form

Hi again, just looking at your reply. The e-mail is sent as a result of the RSForm, right? You should be able to do that as part of step (2) above.

Ok, here are the MetaTemplate-related parts of the steps above:

1 - MetaTemplate rule 1. This will store the referrer if it's not the same as the current site, so that we can retrieve it later.

In the main PHP box of the rule, put the following:

Code:

$host = "http://" . $_SERVER['HTTP_HOST'] . "/";

if ($core_genius->check("referrer not starts with", $host) ) {
  $referrer = $core_genius->info("referrer");
  if ( $referrer == "" ) $referrer = "direct";
  $session =& JFactory::getSession();
  $session->set( 'OrigReferrer', $referrer, 'metatemplate');
}

2 and 3 - You need to embed this code into RSForm, so that it triggers when the conversion is made. I can't remember off the top of my head where this goes, but I know there's a place.

It retrieves quite a lot of information and you will have to find out how to include this in the e-mail to the admin.

It also stores it in the session, so it can be retrieved in your template and sent to GA.

Code:

include_once(JPATH_SITE . DS . "components" . DS . "com_metatemplate" . DS . "JomGenius.class.php");

$session =& JFactory::getSession();
$referrer = $session->get( 'OrigReferrer', '', 'metatemplate');
$mainframe =& JFactory::getApplication();
$template =& $mainframe->getTemplate();
$date = date("c");
$core_genius = JomGenius("core");
$url = $core_genius->info("url");
// create our info string
$info_string = "$date|$template|$url|$referrer";
// put it in the session so we can retrieve it later
$session->set( 'InfoString', $info_string, 'metatemplate');
// exercise for the reader: how to send this in e-mail to admin, from RSForm?

// Now also set the template as a cookie for the user.
// We do it by ID so that users can't manipulate the text
// of the name.
$tmplid = 0;
if ($template == 'my_template_a') $tmplid = 1;
if ($template == 'my_template_b') $tmplid = 2;
if ($template == 'my_template_c') $tmplid = 3;
if ($template == 'my_template_d') $tmplid = 4;
if ($template == 'my_template_e') $tmplid = 5;
if ($template == 'my_template_f') $tmplid = 6;

if ($temp > 0) {
  $tenyears = 60*60*24*365*10;
  setcookie( 'tmplid', $tmplid, time()+$tenyears, '/' );
}

4 - sending the info string to GA

Modify the code I gave you earlier that goes into the bottom of your template, to this:

Code:

<script type="text/javascript">

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXX-X']); // <== put your GA code here
    _gaq.push(['_setCustomVar',
      1,
      'Template',
      'MyTemplateName' // <== customise here for each template
   ]);
<?php
   $session =& JFactory::getSession();
   $info_string = $session->get( 'InfoString', '', 'metatemplate');
   if ($info_string != '') {
     echo "_gaq.push(['_setCustomVar',";
     echo "2,";
     echo "'InfoString',";
     echo "'$info_string'";
     echo "]);";
   }
?>
    _gaq.push(['_trackPageview']);
   (function() {
     var ga = document.createElement('script');
     ga.type = 'text/javascript'; ga.async = true;
     ga.src = ('https:'   == document.location.protocol ? 'https://ssl'   : 'http://www') + '.google-analytics.com/ga.js';
     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
  </script>

5 - a MetaTemplate rule to check for the cookies and set the appropriate template

Put this into the main PHP section of a rule. Ensure that in the SUCCEED action you "proceed to next rule", if there are any more rules that might need to be run.

Code:

$tmplid = (int)JRequest::getVar("templid",0,'cookie');

$tmplid = 0;
if ($tmplid == 1) return 'my_template_a:continue';
if ($tmplid == 2) return 'my_template_b:continue';
if ($tmplid == 3) return 'my_template_c:continue';
if ($tmplid == 4) return 'my_template_d:continue';
if ($tmplid == 5) return 'my_template_e:continue';
if ($tmplid == 6) return 'my_template_f:continue';
return true;

Footnote:
I have tested out some, not all, of the code above. It's quite possible there are typos and other errors, so it could still take some work to get it going. But fundamentally it should work pretty well.


You should really hire me wink

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
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Using JomGenius to retreive valuable information on a submission form

Hi Stephen, I did all the aforementioned coding. The only thing I hesitate is as to where to put the code for RsFormsPro!. There are 2 spaces available for PHP; one for the user email and one for the admin.

It goes like this:

Script called before the User Email is sent.

OR

Script called before the Admin Email is sent.

So I choosed the space for Admin Email and left the other empty. There's also a note that says: "The $adminEmail array contains all the information that will be sent in the email.
You can modify it by adding a PHP script below. Remember to not include the <?php and ?> tags."


So I included the following code:

Code:

include_once(JPATH_SITE . DS . "components" . DS . "com_metatemplate" . DS . "JomGenius.class.php");


$session =& JFactory::getSession();

$referrer = $session->get( 'OrigReferrer', '', 'metatemplate');

$mainframe =& JFactory::getApplication();

$template =& $mainframe->getTemplate();

$date = date("c");

$core_genius = JomGenius("core");

$url = $core_genius->info("url");

// create our info string

$info_string = "$date|$template|$url|$referrer";

// put it in the session so we can retrieve it later

$session->set( 'InfoString', $info_string, 'metatemplate');

// exercise for the reader: how to send this in e-mail to admin, from RSForm?



// Now also set the template as a cookie for the user.

// We do it by ID so that users can't manipulate the text

// of the name.

$tmplid = 0;

if ($template == 'my_template_a') $tmplid = 1;

if ($template == 'my_template_b') $tmplid = 2;

if ($template == 'my_template_c') $tmplid = 3;

if ($template == 'my_template_d') $tmplid = 4;

if ($template == 'my_template_e') $tmplid = 5;

if ($template == 'my_template_f') $tmplid = 6;



if ($temp > 0) {

  $tenyears = 60*60*24*365*10;

  setcookie( 'tmplid', $tmplid, time()+$tenyears, '/' );

}

Now I have really no idea how to do this:

Metamodguy wrote:

"It retrieves quite a lot of information and you will have to find out how to include this in the e-mail to the admin. "

Cheers,
Alex

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

Re: Using JomGenius to retreive valuable information on a submission form

You should be able to get some more help from the good folks at RSJoomla.

How I'd start though: I'd do as they suggest and print out some info from the admin form:

print_r($adminEmail);die();

Then test out filling in the form and see what comes up.

One of the elements of the $adminEmail array will probably be the contents of the e-mail. You can then append the value of $info_string to that part of the array to get it added to the message. I don't know what it is so you'll have to find out from the print_r() above.

Then you'll just do something like:

$adminEmail['body_or_some_keyword_like_that'] .= "And the info string is: $info_string";

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
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Using JomGenius to retreive valuable information on a submission form

Ok I couldn't figure this thing out so I submited a ticket to their helpdesk.

Let's see what happens... I'll get back to you as soon as I get an answer from them.

Cheers,
Alex

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

Re: Using JomGenius to retreive valuable information on a submission form

After browsing the RSForm source code, I think this might work:

$adminEmail['text'] .= "And the info string is: $info_string";


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
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1689
Total Polls:
6
Total Posts:
5941
Posts this week:
1
User Info:
 
Total Users:
5339
Newest User:
trei50809
Members Online:
0
Guests Online:
129

Online: 
There are no members online

Forum Legend:

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