Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show alternate index pages 1

Status
Not open for further replies.

doorbreaker

Programmer
Nov 19, 2002
91
GB
Hi,

I am going to need to offer alternate index pages for each user that visits the site.

So, I would have index1.asp and index2.asp

User 1 gets index1, user2 gets index2, user 3 gets index1, user 4 gets index2 and so on.

Does anyone have any ideas how to do this?

(The reason for this is to see drop off rates for different page layouts)

Many thanks

Chris
 
You could use the Session_onStart event in your global.asa to check an Application variable.

If it is False set it to True and show index1
If it is True set it to False and show index2
 
If you don't want unique users to get both versions of your homepage within the same session then you'll also want to set a session variable.

Or, if it doesnt have to be a hard "every other one" but rather instead just an average of 50/50 then you could not use an Application variable at all but rather instead look at the current seconds in the system time and mod by 2. That should give you half 1s and half 0s.
 
It has to be a hard every other one. And I wouldn't want the user to get both versions of the homepage so a session would indeed be suitable for that.

My only confusion (or lack of knowledge) is how to use an application variable to make sure it is every other one to begin with. I understand using Session_OnStart in the global.asa file but where do I set the application variable?
 
ah, I think I get it, in the global.asa right.

Ok, thanks for the pointers, I will let you know how I do.
 
Well you could set it in the Application_onStart event.

 
Hi,

I've been messing around with this but no joy thus far.

My global.asa has the following:

Code:
Sub Application_onStart 

if Application("WhichIndexPage") = "" then
	
	session("page") = "1"
	
	Application("WhichIndexPage") = "2"

elseif Application("WhichIndexPage") = "2" then

	session("page") = "2"

	Application("WhichIndexPage") = ""

end if

End Sub 


I have the following at the very top of my index.asp page:

[CODE]

<% if session("page") = "2" then

response.redirect "index2.asp"

 end if %>

No joy though. :-(

Any ideas anyone.

Thanks

Chris
 
I was thinking something more along the lines of:
Code:
Sub Application_OnStart
  Application("WhichIndexPage") = 1
End Sub

Sub Session_OnStart
  Application.Lock
  If Application("WhichIndexPage") = 1 Then
    'this time show page 1
    session("page") = 1

    'next time show page 2
    Application("WhichIndexPage") = 2
  Else
    'this time show page 2
    session("page") = 2

    'next time show page 1
    Application("WhichIndexPage") = 1
  End If
  Application.Unlock
End Sub
 
I have replaced the global.asa file with your code but still no joy.

It seems session("page") isn't being set in the global.asa. When I try and output the value of session("page") on any of my pages nothing is shown.

Hmmmm.

Thanks though for your help on this matter.

 
Do your other session variables work?

Perhaps the "Enable Session State" box is not checked in the IIS Admin tool?

Also I just noticed that my code has: session("page") = 1
But your code has: if session("page") = "2" then

It would be best if you either remove the quotes around the number on yours or add them around the numbers in mine... so that the IF/THEN is comparing a string to a string or a number to a number.



 
I modified the if session("page") = "2" to remove the quotes around the 2 and I have also checked the Enable Session State in IIS (this was already checked) but alas, it refuses to play ball.
 
Oh and yeah, other session variables do work - using them for a cart.
 
Ok,

I trimmed the global.asa to:

Code:
Sub Application_OnStart
  session("page") = 1
End Sub

and it still won't set the session variable.

The session is set fine if I run the following anywhere on my site:

Code:
session("page") = 1

This suggests the global.asa file is being called. But it is named correctly and I have it in the root of the application.

Strange.
 
Is the root marked as an "application" in the IIS Admin tool?

When you look at the first property sheet for the root folder in IIS admin, is the topmost button marked "Create" or "Remove" ??? The button I mean along the right side of the property sheet a tad below center. ... By "first" property sheet I mean the one with the tab named "Directory"

 
This button is marked as remove - so it is setup as an application right?
 
Ok, I found the problem and its kinda embarrassing.

I hadn't put <script language="vbscript" runat="server"> </script> around the code in the global.asa file. As I haven't used the global.asa file I didn't know. It also didn't throw up any errors.

Anyway thanks for your help Sheco. It was appreciated.

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top