Skip to content

Commit

Permalink
fixed snippets and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pmeisen committed Nov 16, 2016
1 parent e947697 commit 9bd6644
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 15 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ First of all, you need a valid API-key, which you can get for free at [https://w

**772A-47D7-93A3-4EA9-9D73-85B9-479B-16C6**

There are currently two different end-points available through the API. The first one is used to send data - so called activities - to the engine, whereas the second one is used to retrieve data from it (lookup).
There are currently three different end-points available through the API. The first one is used to send data - so called activities - to the engine, whereas the second is used to retrieve temporal data from the engine for a visitor (e.g., the current city, weather, or the current timezone, or the current holidays), and the last one is used to look up detailed information about your visitor (e.g., first name).

The following code-snippet shows how easy it is to utilize the different end-points:

```html

<!-- load the library -->
<script src="https://cdn.jsdelivr.net/breinify-api/1.0.6/breinify-api.min.js"></script>
<script src="https://cdn.jsdelivr.net/breinify-api/1.0.7/breinify-api.min.js"></script>
<script>
/*
* Configure the library (see 'further links' for a full list)
Expand All @@ -35,6 +35,19 @@ The following code-snippet shows how easy it is to utilize the different end-poi
'email': Breinify.text('input[name="name"]')
}, 'login');
}
/*
* If you want your visitor to see the current weather
* (holidays, location), or if you'd like to know it
* (for analytical purposes or just to personalize the
* store).
*/
Breinify.temporalData(function(data) {
if (typeof data.weather !== 'undefined') {
window.alert('The temperature is currently ' + data.weather.temperature);
}
});
/*
* You may want to greet your visitor appropriately, so let's
* look-up the first name. For a full list of dimensions have
Expand All @@ -60,4 +73,5 @@ To understand all the capabilities of Breinify's DigitalDNA API, you should have
* the [API library documentation](documentation/api.md),
* an [example using Google Tag Manager](documentation/example-google-tag-manager.md),
* a [more comprehensive example](documentation/example-comprehensive.md), or
* the [full API documentation](https://www.breinify.com/documentation/index.html)
* [Breinify's Website](https://www.breinify.com).
2 changes: 1 addition & 1 deletion documentation/snippets/config.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
>
```javascript
<!-- load the library -->
<script src="https://cdn.jsdelivr.net/breinify-api/1.0.6/breinify-api.min.js"></script>
<script src="https://cdn.jsdelivr.net/breinify-api/1.0.7/breinify-api.min.js"></script>
```

>
Expand Down
8 changes: 4 additions & 4 deletions documentation/snippets/temporal.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
> ```javascript
> var withSecret = false;
>
> // Example with just IP address set
> var response = Breinify.temporalData({
> 'ipAddress': '74.115.209.58'
> }, withSecret);
> // Example to retrieve temporal information through available information
> Breinify.temporalData(function(data) {
> window.alert(JSON.stringify(data, null, 2));
> });
> ```
12 changes: 5 additions & 7 deletions documentation/snippets/temporalfull.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
> ```javascript
> var withSecret = false;
>
> // Example with full user data
> var response = Breinify.temporalData({
> 'ipAddress': '74.115.209.58',
> 'localDateTime': 'Wed Oct 26 2016 13:02:06 GMT-0700 (EDT)',
> 'timezone': 'America/New_York'
> }, withSecret);
>
> // Example to retrieve temporal information through additional information
> Breinify.temporalData({ 'email':'example@breinify.com' }, function(data) {
> window.alert(JSON.stringify(data, null, 2));
> });
> ```
20 changes: 19 additions & 1 deletion documentation/step-by-step.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ bower install https://github.com/breinify/brein-api-library-javascript-browser/t
```

##### Using *npm* to download the library
Please pick 1 of the following:
Please pick one of the following:
```bash
npm install breinify/brein-api-library-javascript-browser
npm install github:breinify/brein-api-library-javascript-browser
npm install https://github.com/breinify/brein-api-library-javascript-browser/tarball/master
```

**Note**: We provide a specific library to be used with node, see [here](https://www.npmjs.com/package/breinify-node).

##### Download the library directly from GitHub

or just download the version from [GitHub](https://raw.githubusercontent.com/Breinify/brein-api-library-javascript-browser/master/dist/breinify-api.min.js) directly.
Expand Down Expand Up @@ -102,6 +104,22 @@ A full list of the available utility functions (*Breinify.UTL*) and there purpos

##### Placing look-up triggers

Temporal data can be used to personalize your content, e.g., to change the appearance of the site regarding holidays (even local holidays), weather, part of time (e.g., afternoon, evening), or events.

```html
<script>
Breinify.UTL.events.pageloaded(function () {
Breinify.temporalData(function (data) {
if (!Breinify.UTL.isEmpty(data)) {
window.alert('It is currently ' + data.weather.temperature);
}
});
}
</script>
```
##### Placing look-up triggers
Look-ups are used, e.g., to change the appearance of the site, increase the quality of service by enhancing recommendations or pre-filtering search results. In the following simple example, the site's message is adapted when the page is loaded.
```html
Expand Down

0 comments on commit 9bd6644

Please sign in to comment.