<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mayavi World &#187; wordpress</title>
	<atom:link href="http://mayavi.info/index.php/category/wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://mayavi.info</link>
	<description></description>
	<lastBuildDate>Wed, 04 Apr 2012 07:50:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>WordPress hacks: passing custom session variables in cforms</title>
		<link>http://mayavi.info/index.php/wordpress/wordpress-hacks-passing-custom-session-variables-in-cforms.html</link>
		<comments>http://mayavi.info/index.php/wordpress/wordpress-hacks-passing-custom-session-variables-in-cforms.html#comments</comments>
		<pubDate>Wed, 10 Jun 2009 14:24:44 +0000</pubDate>
		<dc:creator>Ranjeet Walunj</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[campaign tracking in wordpress]]></category>
		<category><![CDATA[cforms]]></category>
		<category><![CDATA[custom variable in Cforms]]></category>
		<category><![CDATA[session variables]]></category>
		<category><![CDATA[tracking online campaigns]]></category>
		<category><![CDATA[website using wordpress]]></category>

		<guid isPermaLink="false">http://mayavi.info/?p=241</guid>
		<description><![CDATA[<p>Many a times people configure and run their entire website using WordPress.</p> <p>cforms is an awesome feature rich plugin for WordPress, offering convenient deployment of multiple Ajax driven contact forms throughout the website. Many wordpress based websites use cforms to capture and store form submissions on their site.</p> <p>Recently came across a requirement where client [...]]]></description>
			<content:encoded><![CDATA[<p>Many a times people configure and run their entire website using WordPress.</p>
<p><a title="Cforms II plugin for wordpress" href="http://www.deliciousdays.com/cforms-plugin" target="_blank">cforms</a> is an awesome feature rich plugin for WordPress, offering convenient deployment of multiple Ajax driven contact forms throughout the website.<br />
Many wordpress based websites use cforms to capture and store form submissions on their site.</p>
<p>Recently came across a requirement where client is running his website on wordpress and also using online marketing campaigns (google, adnetworks)  to drive traffic to his website.</p>
<p>Requirement was to track those custom variables (source, creative name) passed to his website.</p>
<p>Many analytics tools should be able to do this, however he wanted to store the data in surfer cforms submissions in database as well as take some action based on his submission.</p>
<p>This can be achieved using following Steps:</p>
<p>Step 1)   Edit header.php of your wordpress theme and add following lines at the start of the file</p>
<p style="padding-left: 90px;">
<p style="padding-left: 90px;">session_start();<br />
$am_usrc=$_GET['source'];<br />
$am_adunit=$_GET['adunit'];<br />
if (isset($am_usrc)) {<br />
$_SESSION["amSrc"] = $am_usrc;<br />
$_SESSION["amUnit"] = $am_adunit;<br />
}</p>
<p style="padding-left: 90px;">
<p>Note the variable names and use them as per your variable names. Also you can store them in sessions/cookies/database as per your requirement.</p>
<p>Step 2) Now define the variable names in `lib_aux.php` file from plugins/cforms directory in following manner</p>
<p style="padding-left: 90px;">### get variables from session and assign to your temp variables<br />
$sessCampaignSRC = $_SESSION["amSrc"];<br />
$sessCampaignAdUnit = $_SESSION["amUnit"];</p>
<p style="padding-left: 90px;">$m  = str_replace( &#8216;{Referer}&#8217;,        $_SERVER['HTTP_REFERER'], $m );<br />
$m  = str_replace( &#8216;{PostID}&#8217;,        $pid, $m );<br />
$m     = str_replace( &#8216;{Form Name}&#8217;,    $cformsSettings['form'.$no]['cforms'.$no.'_fname'], $m );<br />
$m     = str_replace( &#8216;{Page}&#8217;,        $page, $m );<br />
$m     = str_replace( &#8216;{Date}&#8217;,        $date, $m );<br />
$m     = str_replace( &#8216;{Author}&#8217;,        $find-&gt;display_name, $m );<br />
$m     = str_replace( &#8216;{Time}&#8217;,        $time, $m );<br />
$m     = str_replace( &#8216;{IP}&#8217;,            cf_getip(), $m );<br />
$m     = str_replace( &#8216;{BLOGNAME}&#8217;,    get_option(&#8216;blogname&#8217;), $m );</p>
<p style="padding-left: 90px;">$m     = str_replace( &#8216;{CurUserID}&#8217;,    $CurrUser-&gt;ID, $m );<br />
$m     = str_replace( &#8216;{CurUserName}&#8217;,    $CurrUser-&gt;display_name, $m );<br />
$m     = str_replace( &#8216;{CurUserEmail}&#8217;,$CurrUser-&gt;user_email, $m );</p>
<p style="padding-left: 90px;">$m     = str_replace( &#8216;{Permalink}&#8217;,    $permalink, $m );<br />
$m     = str_replace( &#8216;{Title}&#8217;,        $find-&gt;post_title, $m );<br />
$m     = str_replace( &#8216;{Excerpt}&#8217;,        $find-&gt;post_excerpt, $m );</p>
<p style="padding-left: 90px;">### define your custome variables campaignSRC and campaignAdUnit to store the values from temporary variables<br />
$m = str_replace( &#8216;{campaignSRC}&#8217;, $sessCampaignSRC, $m );<br />
$m = str_replace( &#8216;{campaignAdUnit}&#8217;, $sessCampaignAdUnit, $m );</p>
<p>Note: the variable names and session retrieval &#8230; you can get them from cookies if you&#8217;ve stored them in cookie files<br />
Also make sure variables used have unique names without conflicting with cforms variable names</p>
<p>Step 3) Use the above mentioned custom variable names in cforms while configuring hidden variables and their values.</p>
<p>{campaignSRC}<br />
{campaignAdUnit}</p>
<p>Configure your form accordingly and insert into your normal post and you are done <img src='http://mayavi.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Working example of the same can be found here on following two links</p>
<p>Sample Click through url : <a href="http://mayavi.info/?source=google&amp;adunit=mayavi_ads" target="_blank">http://mayavi.info/?source=google&amp;adunit=mayavi_ads</a></p>
<p>Form url :  <a href="http://mayavi.info/index.php/lamp/cforms-test.html" target="_blank">http://mayavi.info/index.php/lamp/cforms-test.html</a></p>
<p>Check the view source of form page and you&#8217;ll be able to see the above two tracking parameters in your hidden variables.</p>
]]></content:encoded>
			<wfw:commentRss>http://mayavi.info/index.php/wordpress/wordpress-hacks-passing-custom-session-variables-in-cforms.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

