-
☆ A M B ☆
- 2,475 Posts
I’m wanting to do some visitor tracking on a site of mine... we got links coming in from different ad campaigns, and we want to track those in sessions so if they do sign up with our service, we’ll know what ad campaign generated the business.
This can work in any number of ways... what do people recommend? Because you need to have the "session_start()" called before any HTML is sent to the browser, this makes sense to put in a plugin, right? However, we don’t need this on every page, only on a few. We need to start the session and write to it on the landing page (which redirects to some other page), and then we need to read from the $_SESSION array when we process our sign-up form. It would be arguably cleaner to do a session_start() only on the 2 places where we need it.
Anyone have any thoughts?
You can tap into the session_start() thats already called by modx. Just create a snippet which sets a session variable and work from there would be the easiest I think.
ex:
<?php
$output ='';
$output .='session test 1: ';
if(isset($_SESSION['test1'])){
$output .='is set';
}else{
$_SESSION['test1'] = time();
$output .=$_SESSION['test1'];
}
return $output;
?>
-
☆ A M B ☆
- 2,475 Posts
ah... I didn’t realize MODx used session_start() automatically. Well, that makes it even easier.
All I have to do now is set my $_SESSION variable when the visitor hits our redirect page then read from it on the form submission page.
-
☆ A M B ☆
- 24,524 Posts
-
☆ A M B ☆
- 24,524 Posts
Looks like I need to flesh that article out a bit; it never occurred to me that everybody wouldn’t be aware that MODx starts its own sessions!
-
☆ A M B ☆
- 2,475 Posts
Heheh... oh, I’m REALLY good at taking every trivial instruction or assumption completely out of context. That gets annoying in a marriage, but it’s really handy for scrutinizing documentation...
-
☆ A M B ☆
- 24,524 Posts
We’d have gotten along just fine; my husband was always griping about my nit-picking. I like to argue; not fight, but just argue and play around with words.
-
☆ A M B ☆
- 2,475 Posts
Haha... well, at least you know what happened. I’m still doing the postmortem...
-
☆ A M B ☆
- 24,524 Posts