Skip to content

Instantly share code, notes, and snippets.

@asmuth
Created January 3, 2012 21:54

Revisions

  1. Paul Asmuth revised this gist Jan 23, 2012. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,10 @@
    { "_type": "_set_name", "name": "Tingle Tangle Bob", "_session": "mysessiontoken" }

    # set the user picture
    { "_type": "_set_picture", "url": "http:#myhost/123.jpg", "_session": "mysessiontoken" }
    { "_type": "_set_picture", "url": "http://myhost/123.jpg", "_session": "mysessiontoken" }

    # track a pageview
    { "_type": "_pageview", "url": "http://myhost/mypath", "_session": "mysessiontoken" }



  2. Paul Asmuth created this gist Jan 3, 2012.
    49 changes: 49 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    # i hope this helps...

    # to set the username and picture send these events to fm
    # -> you don't need to define any event handlers
    # -> the session token (_session) could be your unique session id
    # or the unique user id (it's hashed)

    # set the user name
    { "_type": "_set_name", "name": "Tingle Tangle Bob", "_session": "mysessiontoken" }

    # set the user picture
    { "_type": "_set_picture", "url": "http:#myhost/123.jpg", "_session": "mysessiontoken" }



    # if you want to count action/events unique per session you can
    # set up an event handler like this:

    gauge :myaction_uniqe,
    :tick => 1.day.to_i,
    :unique => true

    event :myaction do
    incr :myaction_uniqe
    end

    # and send events like this one:
    { "_type": "myaction", "_session": "mysesstiontoken" }

    # the gauge will only be incremented once per session token (and tick/interval)
    # so this gauge would show "daily unique myactions"



    # if you want e.g. the average body size of all users on a given day:

    gauge :average_body_size,
    :tick => 1.day.to_i,
    :unique => true,
    :average => true

    event :user_body_info do
    incr :average_body_size, data[:body_size]
    end

    # events:
    { "_type": "user_body_info", "body_size": 186, "_session": "userid_1" }
    { "_type": "user_body_info", "body_size": 162, "_session": "userid_2" }
    { "_type": "user_body_info", "body_size": 173, "_session": "userid_3" }