https://github.com/loehnertz/pyttribution.io
A Python wrapper around the Attribution.io API
https://github.com/loehnertz/pyttribution.io
api-wrapper attribution-io pypi python python-wrapper wrapper
Last synced: 3 months ago
JSON representation
A Python wrapper around the Attribution.io API
- Host: GitHub
- URL: https://github.com/loehnertz/pyttribution.io
- Owner: loehnertz
- License: mit
- Created: 2017-09-15T07:35:55.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-10-23T00:34:45.000Z (over 5 years ago)
- Last Synced: 2024-10-02T10:18:47.874Z (9 months ago)
- Topics: api-wrapper, attribution-io, pypi, python, python-wrapper, wrapper
- Language: Python
- Homepage: https://pypi.python.org/pypi/pyttributionio
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Pyttribution.io
[](https://badge.fury.io/py/pyttributionio)A Python wrapper around the Attribution.io API
## Installation
```
pip install pyttributionio
```## Usage
Create an instance of the `PyttributionIo()` class while passing your API credentials:
```
pyttributionio = PyttributionIo(
api_key=[YOUR_API_KEY],
api_secret=[YOUR_API_SECRET],
)
```After creating an instance of the class, there are two types of API's one can use.
#### Private API
There's the private one which can be used to retrieve information about any customer within
your Attribution.io account.
There are six options to choose from, they are increasing in returned information quantity:
- `pyttributionio.fetch_customer_info_base(client_id)`:
Returns just the base information set of the chosen customer
- `pyttributionio.fetch_customer_info_pageviews(client_id)`:
Returns just the base information set as well as all the pageviews of the chosen customer
- `pyttributionio.fetch_customer_info_touchpoints(client_id)`:
Returns just the base information set as well as all the touchpoints of the chosen customer
- `pyttributionio.fetch_customer_info_events(client_id)`:
Returns just the base information set as well as all the events of the chosen customer
- `pyttributionio.fetch_customer_info_identities(client_id)`:
Returns just the base information set as well as all the identities of the chosen customer
- `pyttributionio.fetch_customer_info_full(client_id)`:
Returns just the base information set as well as all information from before combined of the chosen customerAs `client_id` one needs to pass an identity used earlier to identify a customer. It can be anything, an integer-based ID, email address etc.
#### Public API
Next to the private API, I also implemented the public API, so that part that the JavaScript snippet is normally POSTing to.You have two options to programmatically use the public API with this wrapper:
- Triggering identities:
```
pyttributionio.trigger_identity(
attributionio_id,
client_id[optional],
user_agent[optional],
)
```- Triggering events:
```
pyttributionio.trigger_event(
attributionio_id,
event_key,
client_id[optional],
user_agent[optional],
last_url[optional],
)
```You need to pass the ID from the cookie which the Attribution.io JavaScript snippet creates for each visitor of your sites as the `attributionio_id`.
The key/name of the cookie in the browser is: `AttrioP_[CLIENT_ID]`
With events you also need to pass an `event_key` which you need to set within the Dashboard of Attribution.io.
Optionally you can pass a custom `client_id` which can be an integer-based ID, an email address etc.
If you don't pass it the wrapper will generate a random identity for you, otherwise events will not be counted.
Additionally, you can pass a user-agent of the customer and the last URL he or she visited on one of your sites.License
-------[MIT](LICENSE.txt)