Tracking the source of users submitting information through Contact Form 7 –

Tracking the source of users submitting information through Contact Form 7 -

[ad_1]

Tracking the source of users sending information via contact form 7 or in short tracking contact form 7 wordpress

To create a contact form, an order form for a WordPress site, in the previous article, I showed you how to use the Contact Form 7 plugin to create a form. But for those who do marketing and advertising, after creating a form, they will need to know how to trace the source of users submitting the form to better analyze user behavior so that they can optimize the ongoing advertising campaign.

Instructions for setting up user source tracking via Contact Form 7:

Step 1: Insert the following code at the end of the file functions.php in the theme you are using.

function wpshore_wpcf7_before_send_mail($array) {
global $wpdb;
if(wpautop($array .)[‘body’]) == $array[‘body’]) // The email is of HTML type
$lineBreak = “
“;
other
$lineBreak = “\n”;
$trackingInfo.= $lineBreak. $lineBreak. ‘–Tracking Information–’. $lineBreak;
$trackingInfo .= ‘Form filling URL: ‘ . $_SERVER[‘HTTP_REFERER’] . $lineBreak;
if (asset ($_SESSION .)[‘OriginalRef’]))
$trackingInfo .= ‘User came from page: ‘ . $_SESSION[‘OriginalRef’] . $lineBreak;
if (asset ($_SESSION .)[‘LandingPage’]))
$trackingInfo.= ‘Landing page before form filling: ‘ . $_SESSION[‘LandingPage’] . $lineBreak;
if ( isset ($_SERVER .)[“REMOTE_ADDR”]))
$trackingInfo .= ‘User IP: ‘ . $_SERVER[“REMOTE_ADDR”] . $lineBreak;
if ( isset ($_SERVER .)[“HTTP_X_FORWARDED_FOR”]))
$trackingInfo .= ‘User proxy server IP: ‘ . $_SERVER[“HTTP_X_FORWARDED_FOR”] . $lineBreak. $lineBreak;
if ( isset ($_SERVER .)[“HTTP_USER_AGENT”]))
$trackingInfo .= ‘Browser information: ‘ . $_SERVER[“HTTP_USER_AGENT”] . $lineBreak;
$array[‘body’] = str_replace(‘[tracking-info]’, $trackingInfo, $array[‘body’]);
returns $array;
}
add_filter(‘wpcf7_mail_components’, ‘wpshore_wpcf7_before_send_mail’);
// Original referrer
wpshore_set_session_values() function
{
if (!session_id())
{
session_start();
}
if (!isset($_SESSION .)[‘OriginalRef’]))
{
$_SESSION[‘OriginalRef’] = $_SERVER[‘HTTP_REFERER’];
}
if (!isset($_SESSION .)[‘LandingPage’]))
{
$_SESSION[‘LandingPage’] = “http://” . $_SERVER[“SERVER_NAME”] . $_SERVER[“REQUEST_URI”];
}
}
add_action(‘init’, ‘wpshore_set_session_values’);

Step 2: Login to your wordpress admin page and Open the form that requires follow-up. Switch to tabs Email Setup and add to the article Contents small code [tracking-info] as following:

Epilogue

That’s all we can say about it. Hope this article will help you in Tracking Contact Form 7 wordpress so that you can track customer behavior thereby maximizing the effectiveness of your advertising campaign.

If you find it interesting, you can follow the wordpress tips section to learn more new knowledge.

Follow the fanpage to receive the latest articles: Hocwordpress Group

Wish you have useful knowledge about worpdress.

first
first
vote

Rate items



[ad_2]

Recommended Posts