JavaScript API - Quick Start
In every page you want to use the NuConomy JavaScript API you must include the following code:<script type="text/javascript">
var _nucjs = (("https:" == document.location.protocol) ? "https://sslf" : "http://f");
document.write(unescape("%3Cscript src='" + _nucjs + ".nuconomy.com/n.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">NUCONOMY.ProjectToken = "XXXXXXXX-XX";
NUCONOMY.Logger.LogActivity( "", "", "", 1, 1); </script>
Note that instead of XXXXXXXX-XX (as illustrated above), you should enter the unique project token that was given to you by NuConomy. If you do not know your project token, please contact NuConomy support at support@nuconomy.com. We generally recommend you place this code where your other analytics tags, if any, are located (e.g. just before the body tag of your page). However, the only requirement in terms of where to place this code on the page is that it must appear before any API call. The NuConomy API includes two methods:
- LogActivity – Used to track an activity into NuConomy. For example, report a page view, comment or post.
- SetContentMetadata – Used to describe metadata of a specific activity done to a specific piece of content. For example the tags associated with a specific blog post.
NUCONOMY.Logger.LogActivity( visitorUserID, contentOwnerUserID, contentID, activityID,
activityValue);
| Parameter Name | Description |
|---|---|
| visitorUserID | Unique ID that identifies a visitor on your site. If the user is anonymous/unknown, you should pass an empty string. |
| contentOwnerUserID | Unique ID that identifies the owner of the piece of content on which the visitor performed an activity. For example, the ID of the author of a blog post. If the content owner is anonymous/unknown, the communication string is empty. |
| contentID | Unique ID that identifies a specific piece of content. Examples are a video ID, a product ID or the permalink of a blog post. |
| activityID | Unique ID that identifies the specific activity. You can get a list of the activities and their IDs under the administration tab in NuConomy Studio at https://studio.nuconomy.com. |
| activityValue | The value associated with the activity you track. For example, the rating that was given to a video or the price of an item that was purchased. |
<script type="text/javascript">
var _nucjs = (("https:" == document.location.protocol) ? "https://" : "http://");
document.write(unescape("%3Cscript src='" + _nucjs + "services.nuconomy.com/n.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">NUCONOMY.ProjectToken = "XXXXXXXX-XX";
NUCONOMY.Logger.LogActivity( “”, “”, “”, 1, 1); </script>
In order to set the metadata associated with specific content you need to use the SetContentMetadata method:
NUCONOMY.Logger.SetContentMetadata (contentID, contentOwnerUserID, contentType,
csvTags );
| Parameter Name | Description |
| contentID | Unique ID that identifies a specific piece of content. Examples are a video ID, a product ID or the permalink of a blog post. |
| contentOwnerUserID | Unique ID that identifies the owner of the piece of content on which the visitor performed an activity. For example the ID of the author of a blog post. If the content owner is anonymous/unknown, the communication string is empty. |
| contentType | A string representing the type of content you wish to track (e.g. profile pages, videos, photos). You will be able to slice most reports in the system by this parameter. |
| csvTags | A list of all tags or categories associated with the specified content. Tags should be separated by a semicolon (;) |
