user3145119
user3145119

Reputation: 11

Tracking conversion variables and success events in SiteCatalyst

There are a couple of things that I didn't understand when I started reading about conversion variables and success events:

  1. How does the conversion variable capture the user's input?

For example: there's a form and there is a visitor's city and age information on that form. The goal is to track the city and age data by two conversion variables when a visitor submits the form. How do I set the tracking code for this?

From some examples on the internet, I can see when people re atalking about setting up conversion variable code, it's like:

s.evar1 = 'somevalue' // which is a static value

I assume this code will pass 'somevalue' to SiteCatalyst. So if I would like to track whatever has been typed by the user, how can I do this?

  1. How can an event be tracked? From what I can see, when people talk about tracking a event, they refer to this kind of code:

    s.events = "event2"; 
    s.eVar1 = "Registration Form"; 
    

However, from my understanding, it won't know when a form is submitted, or when a search is complete. How do I record such an activity in an event?

Upvotes: 1

Views: 1471

Answers (1)

CrayonViolent
CrayonViolent

Reputation: 32517

There is no one-size-fits-all method for it, because everybody's website is differently coded. However, the most reliable way to track information from a form is to output the custom code on the form complete/thank you page. How you populate the values depends on how your website is setup. For example, if the form pages are unique, you can simply hardcode some of the values on the page. But if it's a dynamic page (e.g. a single controller page that outputs different content based on user actions) then you will need to get more creative, likely using server-side logic to determine when to output it. The form values will almost certainly need to be output via server-side logic. Here is a quick and dirty example of how it should look in general, using php as server-side code:

form page (register.html):

<html>
<head></head>
<body>
<h1>register!</h1>
<form action='thankyou.php' method='post'>
email: <input type='text' name='email' />
<input type='submit' name='submit' value='register' />
</form>
<script type='text/javascript' src='s_code.js'></script>
s.events='event1'; // form view event
s.eVar1 = 'registration form'; //
s.t(); // track page view
</script>
</body>
</html>

form compolete page (thankyou.html)

<?php
if ($_POST['email'] && trim($_POST['email'])!='') {

$email = $_POST['email'];

  // do something like put email in database or send email or whatever

?>
<html>
<head></head>
<body>
<h1>thanks for registering!</h1>
<script type='text/javascript' src='s_code.js'></script>
s.events='event2'; // form complete event
s.eVar2='<?php echo $email; ?>'; // email address
s.t(); // track page view
</script>
</body>
</html>
<?php
} else {
  // user did not complete form, send them back to form
  header('Location: register.html'); exit();
}
?>

In this example, I have event1 to signify a form view, and eVar1 to signify what type of form it is. Since the form is on its own page register.html, I can simply hardcode those values on the form page.

Then thankyou.html handles the submitted form. After validating the form values, if everything is right, you output the thank you message and the tracking code. Since the thank you page is its own page, I can hardcode event2 (form complete) event. But I need to use php to output the value for eVar2 (email address).

But your website code very likely looks nothing like this. So that is your job as the website dev to figure out. You should first figure out what you want to track, and assign appropriate SiteCatalyst variables. Then it's up to you to figure out how best to populate them, based on how your website is coded.

Upvotes: 1

Related Questions