Using URL Tokens In .Net

As all SpeedPPC users know when you build a campaign the URL Template Tab is where you can build unique URLs using the SpeedPPC dynamic token system – if you are creating dynamic landing pages this is how the values will be passed on into your landing page content. This is designed to work with dynamic landing pages written in .PHP.

SpeedPPC generates the .PHP page code for you as well.

But what if you have dynamic landing pages that are built in .NET? Is it possible to use this .PHP code in that environment?

The answer is yes.

Below is the required code that will allow you to use URL tokens in .NET using C# or VB.

Using URL Token In .NET (C# Version)

1.) The code below will get KEYWORDS Value.

Note: Do not remove any of the code within <script runat=”server”>…</script>, otherwise..these variables: (<%=seed%?>, <%=expansion%?> and <%=final%?>) will be unassigned.

<%@ Page %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<script runat=”server”>

private string _seed = “”;

private string _expansion = “”;

private string _final = “”;

public string seed

{

get { return _seed; }

set { _seed = value; }

}

public string expansion

{

get { return _expansion; }

set { _expansion = value; }

}

public string final

{

get { return _final; }

set { _final = value; }

}

protected void Page_Load(object sender, EventArgs e)

{

_seed = (!string.IsNullOrEmpty(Request[“seed”])) ? Request[“seed”].Replace(“-“, ” “) : “”;

_expansion = (!string.IsNullOrEmpty(Request[“expansion”])) ? Request[“expansion”].Replace(“-“, ” “) : “”;

_final = (!string.IsNullOrEmpty(Request[“final”])) ? Request[“final”].Replace(“-“, ” “) : “”;

}

</script>

<html xmlns=”http://www.w3.org/1999/xhtml”>

<head runat=”server”>

<title><%=final %></title>

<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>

<meta name=”description” content=”<%=final %>”>

<meta name=”keywords” content=”<%=final %>, <%=seed %>”>

</head>

<body>

<table width=”700″ border=”0″ align=”center” cellpadding=”0″ cellspacing=”0″ height=”90″>

<tr>

<td valign=”middle”>

<h2><strong>Direct <%=seed %></strong></h2>

</td>

<td  valign=”middle”>

<h2><strong>We specialize in <%=seed %><br>Finding you the best details on <%=seed %></strong></h2>

</td>

</tr>

</table>

<br>

<table width=”700″ border=”0″ align=”center” cellpadding=”1″ cellspacing=”0″ bgcolor=”#999999″>

<tr>

<td>

<table width=”700″ border=”0″ align=”center” cellpadding=”10″ cellspacing=”0″ bgcolor=”#FFFFFF”>

<tr>

<td>

<h3><em><strong><font color=”#CC0000″>Top of the line <%=seed %></font></strong></em></h3>

<p align=”left”><em><strong><%=seed %></strong> lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod   tempor incididunt ut labore et dolore magna aliqua. <strong><%=seed %></strong> ut enim ad minim veniam,   quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo   consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum   dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,   sunt in culpa qui officia deserunt mollit anim id est laborum.</em></p>

</td>

</tr>

</table>

</td>

</tr>

</table>

</body>

</html>

2.) Below are the variables/Tokens where you can placed anywhere in your content. The values are already assigned from the above code.

For Seed:        <%=seed %>

For Expansion:            <%=expansion %>

For Final:         <%=final %>

3.) If you want to add another token. Add the following code within script tag as you can see on number 1 Instruction right after this line (private string _final = “”;):

Private _expansion1 As String = “”

Public Property expansion1() As String

Get

Return _expansion1

End Get

Set(ByVal value As String)

_expansion1 = value

End Set

End Property

———-> Continuation:Right after the following line:

_final = (!string.IsNullOrEmpty(Request[“final”])) ? Request[“final”].Replace(“-“, ” “) : “”;

———-> Continuation:Add the following code:

_expansion1 = (!string.IsNullOrEmpty(Request[“expansion1”])) ? Request[“expansion1”].Replace(“-“, ” “) : “”;

Using URL Token In .NET (VB Version)

1.) The code below will get KEYWORDS Value.

Note: Do not remove any of the code within <script runat=”server”>…</script>, otherwise..these variables: (<%=seed%?>, <%=expansion%?> and <%=final%?>) will be unassigned.

<%@ Page %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<script runat=”server”>

Private _seed As String = “”

Private _expansion As String = “”

Private _final As String = “”

Public Property seed() As String

Get

Return _seed

End Get

Set(ByVal value As String)

_seed = value

End Set

End Property

Public Property expansion() As String

Get

Return _expansion

End Get

Set(ByVal value As String)

_expansion = value

End Set

End Property

Public Property final() As String

Get

Return _final

End Get

Set(ByVal value As String)

_final = value

End Set

End Property

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

If Not String.IsNullOrEmpty(Request(“seed”)) Then

_seed = Request(“seed”).Replace(“-“, ” “)

End If

If Not String.IsNullOrEmpty(Request(“expansion”)) Then

_expansion = Request(“expansion”).Replace(“-“, ” “)

End If

If Not String.IsNullOrEmpty(Request(“final”)) Then

_final = Request(“final”).Replace(“-“, ” “)

End If

End Sub

</script>

<html xmlns=”http://www.w3.org/1999/xhtml”>

<head runat=”server”>

<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>

<meta name=”description” content=”<%=final %>”>

<meta name=”keywords” content=”<%=final %>, <%=seed %>”>

</head>

<body>

<table width=”700″ border=”0″ align=”center” cellpadding=”0″ cellspacing=”0″ height=”90″>

<tr>

<td valign=”middle”>

<h2><strong>Direct <%=seed %></strong></h2>

</td>

<td  valign=”middle”>

<h2><strong>We specialize in <%=seed %><br>Finding you the best details on <%=seed %></strong></h2>

</td>

</tr>

</table>

<br>

<table width=”700″ border=”0″ align=”center” cellpadding=”1″ cellspacing=”0″ bgcolor=”#999999″>

<tr>

<td>

<table width=”700″ border=”0″ align=”center” cellpadding=”10″ cellspacing=”0″ bgcolor=”#FFFFFF”>

<tr>

<td>

<h3><em><strong><font color=”#CC0000″>Top of the line <%=seed %></font></strong></em></h3>

<p align=”left”><em><strong><%=seed %></strong> lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod   tempor incididunt ut labore et dolore magna aliqua. <strong><%=seed %></strong> ut enim ad minim veniam,   quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo   consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum   dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,   sunt in culpa qui officia deserunt mollit anim id est laborum.</em></p>

</td>

</tr>

</table>

</td>

</tr>

</table>

</body>

</html>

2.) Below are the variables/Tokens where you can placed anywhere in your content. The values are already assigned from the above code.

For Seed:        <%=seed %>

For Expansion:            <%=expansion %>

For Final:         <%=final %>

3.) If you want to add another token. Add the following code within script tag as you can see on number 1 Instruction right after this line (Private _final As String = “”):

Private _expansion1 As String = “”

Public Property expansion1() As String

Get

Return _expansion1

End Get

Set(ByVal value As String)

_expansion1 = value

End Set

End Property

———-> Continuation:Right after the following line:

If Not String.IsNullOrEmpty(Request(“final”)) Then

_final = Request(“final”).Replace(“-“, ” “)

End If

———-> Continuation:Add the following code:

If Not String.IsNullOrEmpty(Request(“expansion1”)) Then

_final = Request(“expansion1”).Replace(“-“, ” “)

End If

Using either of these methods will allow you to parse tokens through .NET landing pages via the URL.

Attached are template files for both versions. Now go and forth and prosper!

Special thanks to Niñ0 for providing the code.

template-vb

template-csharp

One Comment on “Using URL Tokens In .Net”

Leave a Reply

Your email address will not be published. Required fields are marked *