Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New API Interface #2

Open
jamztang opened this issue Feb 19, 2017 · 0 comments
Open

New API Interface #2

jamztang opened this issue Feb 19, 2017 · 0 comments

Comments

@jamztang
Copy link
Member

jamztang commented Feb 19, 2017

Question:

before we track, is that right we have to manually make sure the .choose has completed, and persist them some where, so next time user land on the same page, the chosen one is loaded from cache

but we may have two or more experiment, say "headline" and "button". Then it gets a bit more complicated, because you have to wait for two async call to complete to track

since it's not a trivial one to one callback, but also getting from cache and multiple callbacks, it'd be good to have the SDK actually handles that all for user

it sounds like we needed to provide a promise style interface to satisify this requirement

var improveai = ImproveAI("apikey", "userid");

var funnel = ["Viewed", "Clicked", "Purchase Succeed"];

var headlinePromise = improveai.choose("headline", ["Self Improving App SDK", "Continous Conversion Optimization"], funnel);

var buttonPromise = improveai.choose("button", ["Request Access", "Try Now"], funnel);

var pagePromise = new Promise([headlinePromise, buttonPromise]);

pagePromise.completed(function(properties) {
  $("headline").html = properties["headline"];
  $("button").html = properties["button"];
  improveai.track("Viewed", properties);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant