keen / common-web

Turn web user activity into a analyzable stream of JSON event data
MIT License
493 stars 62 forks source link

Form field changes #12

Closed josephwegner closed 9 years ago

josephwegner commented 9 years ago

This adds a new tracking function, trackInputChanges. That will bind on the change event of all inputs on the page, and track them. It tracks the previous value, and also passes along information about the parent form, if available.

I also fixes two bugs in trackFormSubmissions:

josephwegner commented 9 years ago

Here's an example event definition for an input change:

{
    "page_url": "http://localhost:3000/index.html",
    "referrer_url": "http://localhost:3000/",
    "keen": {
        "addons": [{
            "name": "keen:ip_to_geo",
            "input": {
                "ip": "ip_address"
            },
            "output": "ip_geo_info"
        }, {
            "name": "keen:ua_parser",
            "input": {
                "ua_string": "user_agent"
            },
            "output": "parsed_user_agent"
        }, {
            "name": "keen:url_parser",
            "input": {
                "url": "page_url"
            },
            "output": "parsed_page_url"
        }, {
            "name": "keen:referrer_parser",
            "input": {
                "referrer_url": "referrer_url",
                "page_url": "page_url"
            },
            "output": "referrer_info"
        }]
    },
    "ip_address": "${keen.ip}",
    "user_agent": "${keen.user_agent}",
    "element": {
        "value": "facepalm",
        "form": {
            "tagName": "FORM",
            "method": "GET",
            "action": "./index.html",
            "data-six": "six",
            "path": "html > body > form"
        },
        "tagName": "INPUT",
        "type": "text",
        "name": "text field",
        "id": "text_field",
        "placeholder": "Type something",
        "path": "html > body > form > input#text_field",
        "previousValue": "test"
    },
    "event": {
        "type": "change",
        "metaKey": false
    }
}
joshed-io commented 9 years ago

Most fantastic. Some interesting applications here around text but also select boxes, radios, and the like.

joshed-io commented 9 years ago

Looks like you might need to rebase your branch onto updated master before we merge in. If you can take care of that we should be all set.

josephwegner commented 9 years ago

Will rebase tomorrow. Thanks!

— Sent from Mailbox

On Tue, Mar 3, 2015 at 7:26 PM, Josh Dzielak notifications@github.com wrote:

Looks like you might need to rebase your branch onto updated master before we merge in. If you can take care of that we should be all set.

Reply to this email directly or view it on GitHub: https://github.com/keen/common-web/pull/12#issuecomment-77079545

josephwegner commented 9 years ago

OK, changed the event name, and rebased. Should be good to go now.

joshed-io commented 9 years ago

Merged!