# Developer Guide For Installation

A guide to installing Zata for those who know how to code.&#x20;

The following help articles will help with installation:&#x20;

* For a developer with knowledge of how their product tracks user properties and events, implementation requires an hour or more of work.

#### Add the Zata SDK snippet

**Place** the following code snippet at the top of the document  `<head>`. The Zata ID can be found on the settings page in your account&#x20;

```
<script>
  window.zataProductConfig = {
    secret: "appsecret"
  };
</script>
<script src="https://app.zata.io/js/zata-embed.js"></script>
<script>
  zataProduct.identify( 
    "UNIQUE USER ID", // Used to identify users 
    { 
         name: "John Doe", // Full name 
         email: "customer@example.com", // Email address 
         created_at: "1519205055" // Signup date as a Unix timestamp 
        // Additional user properties 
        // projectId: "1"
        // trialEnds: '2019-10-31T09:29:33.401Z'
    }     
  );
</script>
```

Make sure to add the script on every page you want to use Zata.

**Re-initialize Zata upon page changes.**

Zata relies on page changes to trigger content. If your application is a single page app (SPA), you'll need to use the `zata.page()` call whenever the page changes.&#x20;

If your application is not a single page app, you may still will want to use the `zata.page()` call if your application changes a large amount of content on a page with JavaScript.

#### Identify users and sending user properties

In order to target content to the right users at the right time, you need to identify users and send Zata data about them.&#x20;

* **Recommended:**&#x20;
* identify users with a unique ID
* pass in user properties (i.e. things like email address, first name, last name, etc.). You do not *have* to pass in any PII.
* If you're installing for someone else and they filled out an installation plan, you can use it as a reference for what user properties to include. Make sure you include at least the properties included in the user property snippet in the installation guide.

Sample identify call:

#### Tracking events

Use the   `Zata.track()` call to track actions users take in your application.

Tracking events lets you target Zata content based on actions people have or have not taken in your application, and also see the impact of your flow content on user behaviors.

If you're installing for someone else and they filled out an installation plan, you can use it as a reference for what events to include.&#x20;

* **Recommended:** If you use an analytics tool (e.g Mixpanel, Google Analytics, Heap, Hotjar, etc.), add an `zata.track()`  call anywhere you track events for that platform.
* Ensure `zata.identify()` or `zata.anonymous()` (or the `analytics.js` equivalent) has been called before tracking events.

```
Zata.track("Event Name"); // e.g. "Clicked Some Button"

Zata.track("Another Event", { // e.g. "Submitted a Help Ticket"
  url: "/support",
  article:"installation"
)};
```

note: Event tracking will not backfill event data. It users completed events before they were being tracked we recommend identifying those users with a custom property.&#x20;

#### Verify that everything is working.

Steps for verifying your installation are available on the of the installation guide.&#x20;

* The verification step will list out each domain in your application where Zata has requested a script. If you want to use Zata on a domain that you don't see listed there, make sure you have added the script to the appropriate page.&#x20;
* To confirm that page tracking is working, open the Zata debugger by appending `?hey_zata` to the URL of any page where Zata is installed. Navigate around and confirm Zata tracks each page change.
* To confirm that user identification is working and that user properties are being sent, confirm the "User identify" section is checked in the Zata debugger. Expand the section to confirm that all properties are accurate.
* To confirm that events are being tracked, trigger one of the `Zata.track()` calls you added and confirm it appears on the events page in Zata.
