> For the complete documentation index, see [llms.txt](https://evntaly.gitbook.io/evntaly/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://evntaly.gitbook.io/evntaly/sdks/go.md).

# Go

The Evntaly Go SDK provides an efficient and robust way to integrate event tracking, user identification, and analytics into your Go applications.

{% embed url="<https://github.com/Evntaly/evntaly-go>" %}

## Installation

Install the Evntaly Go SDK using the Go package manager:

```go
 go get github.com/Evntaly/evntaly-go
```

## Initialization

Initialize the SDK with your **Developer Secret** and **Project Token -** Check [Here](/evntaly/getting-started.md#create-pat-for-your-project)&#x20;

```go
package main

import (
    "github.com/Evntaly/evntaly-go"
    "fmt"
)

func main() {
    evntaly := evntaly.NewEvntalySDK("YOUR_DEVELOPER_SECRET", "YOUR_PROJECT_TOKEN")
    fmt.Println("Evntaly SDK initialized!")
}
```

## Tracking Events

For custom event tracking, use the **Track** method.

```go
 event := evntaly.Event{
     Title:       "Payment Received",
     Description: "User completed a purchase",
     Message:     "Order #12345",
     Data: map[string]interface{}{
         "user_id": "67890",
         "timestamp": "2025-01-08T09:30:00Z",
         "referrer": "social_media",
         "email_verified": true,
         "amount": 149.99,
         "currency": "USD",
         "payment_method": "Credit Card",
     },
     Tags:       []string{"purchase", "payment", "ecommerce"},
     Notify:     true,
     Icon:       "💰",
     ApplyRuleOnly: false,
     User:       evntaly.User{ID: "12345"},
     Type:       "Transaction",
     SessionID:  "20750ebc-dabf-4fd4-9498-443bf30d6095_bsd",
     Feature:    "Checkout",
     Topic:      "@Sales",
 }
 err := evntaly.Track(event)
 if err != nil {
     fmt.Println("Error tracking event:", err)
 }
```

## User Identification

Identify a user to associate events with a specific profile.

```go
 user := evntaly.User{
     ID:           "12345",
     Email:        "user@example.com",
     FullName:     "John Doe",
     Organization: "ExampleCorp",
     Data: map[string]interface{}{
         "id": "JohnD",
         "email": "user@example.com",
         "location": "USA",
         "salary": 75000,
         "timezone": "America/New_York",
         "subscription_plan": "Premium",
         "last_login": "2025-02-24T15:30:00Z",
     },
 }
 err := evntaly.IdentifyUser(user)
 if err != nil {
     fmt.Println("Error identifying user:", err)
 }
```

## Enabling and Disabling Tracking

You can enable or disable event tracking globally.

```go
 evntaly.DisableTracking()  // Disables tracking
 evntaly.EnableTracking()   // Enables tracking
```

## Methods

<table><thead><tr><th>Method</th><th width="209.21875">Description</th><th>Example Usage</th><th>Available Since</th></tr></thead><tbody><tr><td><code>NewEvntalySDK</code></td><td>Initializes the SDK with API credentials.</td><td><code>evntaly.NewEvntalySDK(token, projectName)</code></td><td>v1.0.0</td></tr><tr><td><code>Track</code></td><td>Tracks a custom event.</td><td><code>evntaly.Track(event)</code></td><td>v1.0.0</td></tr><tr><td><code>IdentifyUser</code></td><td>Identifies a user for analytics.</td><td><code>evntaly.IdentifyUser(user)</code></td><td>v1.0.0</td></tr><tr><td><code>DisableTracking</code></td><td>Disables all event tracking.</td><td><code>evntaly.DisableTracking()</code></td><td>v1.0.0</td></tr><tr><td><code>EnableTracking</code></td><td>Enables all event tracking.</td><td><code>evntaly.EnableTracking()</code></td><td>v1.0.0</td></tr></tbody></table>

## Best Practices

* **Initialize early:** Always initialize the SDK as early as possible.
* **Avoid sensitive data:** Do not pass sensitive personal data directly to the SDK.
* **Monitor API limits:** Regularly check API limits to avoid missing critical events.

## Troubleshooting

* **Events not appearing:** Check if the SDK is initialized correctly and the API tokens are valid.
* **Network errors:** Ensure your network allows requests to `https://evntaly.com`.

***

## Support

For additional help, contact support at **<support@evntaly.com>**.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://evntaly.gitbook.io/evntaly/sdks/go.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
