awe.sm Conversion Tracking with JavaScript

You must enable conversion tracking on your project before continuing.

Including the awe.sm JavaScript

You must include the awe.sm JavaScript library on every page where you want conversions tracked—including the initial shared page, otherwise no conversions will be captured.

The awe.sm library should be loaded asynchronously to ensure your page renders as fast as possible.

<script>
var AWESM = AWESM || {};
AWESM.api_key = 'XXXXXXXXXX';                 

(function() {
    var js = document.createElement('script'); js.type = 'text/javascript'; js.async = true;
    js.src = '//widgets.awe.sm/v3/widgets.js?key=' + AWESM.api_key + '&async=true';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(js,s);
})();
</script> 

It can also be loaded directly. In many browsers, page rendering will pause while scripts are loaded, so we recommend putting script tags such as this one as close to the bottom of your markup as possible.

<script src="//widgets.awe.sm/v3/widgets.js?key=XXXXXXXXXX"></script>

Replace XXXXXXXXXX with your own awe.sm API key, found in Project Settings. Note: This script is the same as the one used to generate our Share Buttons, so if you use both, you only need to include the script once.

Registering conversion goals

When users accomplish a conversion goal, use the AWESM.convert JavaScript method. You'll specify which conversion goal and the value of the goal, if applicable. Page views will automatically be registered.

JSAWESM.convert(goal, value)

Required Parameters

Parameter Type Description
goal string Which of the ten goals has been accomplished: goal_1, goal_2, goal_3, goal_4, goal_5, goal_6, goal_7, goal_8, goal_9, or goal_10
value integer

The integer value of the conversion. If there is no value associated with the conversion, specify 0.

Because it is an integer, if you are specifying a precise dollar value, we recommend specifying the value in cents, e.g. $1.57 would be 157, $10 would be 1000. This does not have to be a dollar value — you can set any value and our APIs will sum the values for you.

Optional Parameters

Parameter Type Description
conversion_id string An arbitrary identifier you can supply to identify this individual conversion, such as your application's internal transaction id. 50 character max.
conversion_user_id string An arbitrary identifier you can supply to identify this user later, such as your application's internal user id. 50 character max.

Related

Examples

If you'd like to track when a new user joins your website as goal_1, this script would be placed on the successful user registration page:

<script>
    AWESM.convert('goal_1', 0);
</script>

Note: There is no monetary value to this conversion, so 0 is passed for the value.


If you'd like to count a user making a purchase for $3.50 as goal_2, this script would be placed on the order confirmation page:

<script>
    AWESM.convert('goal_2', 350);
</script>

All your calls for any individual goal do not need to have equal values, so you can call goal_2 with a value other than 350 for another conversion later on.

Last updated 2012-09-05