Profile widget

With this widget, you can advertise yourself on Odnoklassniki. It will allow your website’s visitors to subscribe literally in one click.

Your profile should be open for viewing

Widget constructor

Widget settings

Profile ID
Width
Height
Type

Result

Code to insert

How to get the ID of your profile

  1. On portal toolbar (top right) open menu below your avatar icon.
  2. Select an option “Settings”.
  3. At the bottom of the page that appears find the label “Your profile ID”.
  4. Copy the ID and paste it into the widget embed code.

Friendship or subscription event tracking

If user has subscribed to you or sent a friendship invite a postMessage will be sent to your page.

Message data in case of subscription:

ok_subscribe$__okProfile1

Message data in case of friendship invite:

ok_invite$__okProfile1

You can track event on page with widget by the following javascript code:

function listenForUserAction() {
    if (window.addEventListener) {
        window.addEventListener('message', onUserAction, false);
    } else {
        window.attachEvent('onmessage', onUserAction);
    }
}

function onUserAction(e) {
    var args = e.data.split("$");
    if (args[0] == "ok_subscribe") {
        onSubscribe(e)
    }

    if (args[0] == "ok_invite") {
        onInvite(e)
    }
}

function onSubscribe(e) {
    alert("User has subscribed to you");
}

function onInvite(e) {
    alert("User has sent a friendship invite to you");
}


listenForUserAction();