# adobedtm-service
Angular service for the Adobe DTM data layer

## Installation

You can install this package using `npm`:

```shell
npm install adobedtm-service --save
```

Include the script `node_modules/adobedtm-service/release/adobeDTM.factory.min.js` in your build process, or add it via a `<script>` tag to your `index.html`

Add `Analytics` as a dependency in your app.

## Usage
```js

angular.module('App', [
  'wb.analytics'
])
.controller('MyAppController', function MyAppController($scope, Analytics) {

  // Initialize the Adobe endpoint and siteType values in the library
  Analytics.init(endpoint, siteType);

  Analytics.add({
  	prop1: 'value1',
  	prop2: 'value2'
  });

  //To fire satellite tracking
  Analytics.track('pageLoaded', {
    endpoint: endpoint,
    siteType: siteType
  });
});
```

### Public methods
```
init(endpoint: string, siteType?: string)
```
Initialize the Adobe endpoint and siteType values in the library by invoking the init method from the controller

```
add(properties: {
    pageName: pageName,
    pageType: pageType
})
```
This will create the analyticsData object which will be added to the window object(!) for collection by the tracking library.


```
track(event: string, options?: {
    endpoint: endpoint,
    siteType: siteType
});
```
The track() method should be invoked after the add() call to trigger an event which the Adobe DTM listens for.
Optionally, endpoint and siteType can also be passed in a configuration object.

