Also Viewing

API Documentation


Basic API Details

Adding Also Viewing does not require any server side code. All you need to do is include our Javascript and configure it on any page you want Also Viewing's help.

Here's our JS:

<script type="text/javascript"
        src="//js.alsoviewing.com/v1"
        data-site-id="12345-12345-12345-12345">
</script>

Feel free to include that on every page if you want, but it will only become active when you call AlsoViewing.config.

To configure a page you want guarded, tell our JS which page and user are currently active.

AlsoViewing.config({
    Page: "/widgets/123",
    User: "Joe Schmoe",
});

What are Page and User?

Page identifies the current resource. You can use dom_id in Rails to get a unique string from a model. However, RESTful URL's typically uniquely identify resources, so this usually works:

AlsoViewing.config({
    Page: location.href,
    User: "Joe Schmoe",
});

User identifies the who is viewing the page. You usually want something like this:

AlsoViewing.config({
    Page: "/widgets/123",
    User: "<%= current_user.full_name %>",
});

What if the user's name isn't necessarily unique?

That's fine. You can specify a user id and display name separately.

AlsoViewing.config({
    Page: "/widgets/123",
    User: {
        Id: "123",
        Name: "Joe Schmoe",
    },
});

Have the basic API down, but want to learn more about what else you can do with Also Viewing?

Check out our advanced API.