{"id":37124340,"url":"https://github.com/mrz1836/go-customerio","last_synced_at":"2026-01-14T14:22:18.952Z","repository":{"id":38361103,"uuid":"364336340","full_name":"mrz1836/go-customerio","owner":"mrz1836","description":":link: Unofficial Golang client for the Customer.io API","archived":false,"fork":true,"pushed_at":"2025-04-14T19:41:36.000Z","size":327,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T20:36:37.749Z","etag":null,"topics":["api","customerio","go","library"],"latest_commit_sha":null,"homepage":"https://customer.io/docs/api/","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"customerio/go-customerio","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrz1836.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null}},"created_at":"2021-05-04T17:34:02.000Z","updated_at":"2025-04-14T19:41:33.000Z","dependencies_parsed_at":"2023-10-12T07:07:54.083Z","dependency_job_id":null,"html_url":"https://github.com/mrz1836/go-customerio","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/mrz1836/go-customerio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrz1836%2Fgo-customerio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrz1836%2Fgo-customerio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrz1836%2Fgo-customerio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrz1836%2Fgo-customerio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrz1836","download_url":"https://codeload.github.com/mrz1836/go-customerio/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrz1836%2Fgo-customerio/sbom","scorecard":{"id":665024,"data":{"date":"2025-08-11","repo":{"name":"github.com/mrz1836/go-customerio","commit":"389b971c8c46e6b5dec6b35f602754132de7d4cc"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":6.1,"checks":[{"name":"Code-Review","score":-1,"reason":"Found no human activity in the last 15 changesets","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: .github/SECURITY.md:1","Info: Found linked content: .github/SECURITY.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: .github/SECURITY.md:1","Info: Found text in security policy: .github/SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Maintained","score":0,"reason":"project is archived","details":["Warn: Repository is archived."],"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1","Warn: topLevel 'contents' permission set to 'write': .github/workflows/release.yml:13","Warn: no topLevel permission defined: .github/workflows/run-tests.yml:1","Warn: no topLevel permission defined: .github/workflows/sync-labels.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/mrz1836/go-customerio/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/mrz1836/go-customerio/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:57: update your workflow using https://app.stepsecurity.io/secureworkflow/mrz1836/go-customerio/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:71: update your workflow using https://app.stepsecurity.io/secureworkflow/mrz1836/go-customerio/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/mrz1836/go-customerio/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/mrz1836/go-customerio/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/mrz1836/go-customerio/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/run-tests.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/mrz1836/go-customerio/run-tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/run-tests.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/mrz1836/go-customerio/run-tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/run-tests.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/mrz1836/go-customerio/run-tests.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/run-tests.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/mrz1836/go-customerio/run-tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/sync-labels.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/mrz1836/go-customerio/sync-labels.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/sync-labels.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/mrz1836/go-customerio/sync-labels.yml/master?enable=pin","Info:   0 out of  10 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/release.yml:16"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":10,"reason":"SAST tool is run on all commits","details":["Info: SAST configuration detected: CodeQL","Info: all commits (30) are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T17:43:01.953Z","repository_id":38361103,"created_at":"2025-08-21T17:43:01.953Z","updated_at":"2025-08-21T17:43:01.953Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28422764,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T13:30:50.153Z","status":"ssl_error","status_checked_at":"2026-01-14T13:29:08.907Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","customerio","go","library"],"created_at":"2026-01-14T14:22:18.093Z","updated_at":"2026-01-14T14:22:18.943Z","avatar_url":"https://github.com/mrz1836.png","language":"Go","funding_links":["https://github.com/sponsors/mrz1836"],"categories":[],"sub_categories":[],"readme":"# CustomerIO (Unofficial Fork)\n\u003e A golang client for the [Customer.io](https://customer.io) [event API](https://customer.io/docs/api/#section/Overview). [(Visit the Original repo/library)](https://github.com/customerio/go-customerio)\n\n[![Release](https://img.shields.io/github/release-pre/mrz1836/go-customerio.svg?logo=github\u0026style=flat\u0026v=1)](https://github.com/mrz1836/go-customerio/releases)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/mrz1836/go-customerio/run-tests.yml?branch=master\u0026logo=github\u0026v=2)](https://github.com/mrz1836/go-customerio/actions)\n[![Report](https://goreportcard.com/badge/github.com/mrz1836/go-customerio?style=flat\u0026v=1)](https://goreportcard.com/report/github.com/mrz1836/go-customerio)\n[![codecov](https://codecov.io/gh/mrz1836/go-customerio/branch/master/graph/badge.svg?v=1)](https://codecov.io/gh/mrz1836/go-customerio)\n[![Go](https://img.shields.io/github/go-mod/go-version/mrz1836/go-customerio?v=1)](https://golang.org/)\n\n\u003cbr/\u003e\n\n## Table of Contents\n- [Installation](#installation)\n- [Documentation](#documentation)\n- [Examples \u0026 Tests](#examples--tests)\n- [Benchmarks](#benchmarks)\n- [Code Standards](#code-standards)\n- [Usage](#usage)\n- [Maintainers](#maintainers-of-the-fork)\n- [Contributing](#contributing)\n- [License](#license)\n\n\u003cbr/\u003e\n\n## Installation\n\n**go-customerio** requires a [supported release of Go](https://golang.org/doc/devel/release.html#policy).\n```shell script\ngo get -u github.com/mrz1836/go-customerio\n```\n\n\u003cbr/\u003e\n\n## Documentation\nView the generated [documentation](https://pkg.go.dev/github.com/mrz1836/go-customerio)\n\n[![GoDoc](https://godoc.org/github.com/mrz1836/go-customerio?status.svg\u0026style=flat)](https://pkg.go.dev/github.com/mrz1836/go-customerio)\n\n### Features\n- [Client](client.go) is completely configurable\n- Using default [heimdall http client](https://github.com/gojek/heimdall) with exponential backoff \u0026 more\n- Use your own custom HTTP client\n- Current coverage for the [customer.io API](https://customer.io/docs/api/#section/Overview)\n  - [x] Authentication\n    - [x] Find your account region\n    - [x] Test Track API keys\n  - [ ] Customers\n    - [x] Add or update a customer\n    - [x] Delete a customer\n    - [x] Add or update a customer device\n    - [x] Delete a customer device\n    - [ ] Suppress a customer profile\n    - [ ] Unsuppress a customer profile\n    - [ ] Custom unsubscribe handling\n  - [ ] Events\n    - [x] Track a customer event\n    - [x] Track an anonymous event\n    - [ ] Report push metrics\n  - [x] Transactional Emails  \n    - [x] Send a transactional email\n  - [ ] Trigger Broadcasts\n    - [ ] Trigger a broadcast\n    - [ ] Get the status of a broadcast\n    - [ ] List errors from a broadcast\n  - [ ] **Beta API** (Customers)\n    - [ ] Get customers by email\n    - [ ] Search for customers\n    - [ ] Lookup a customer's attributes\n    - [ ] List customers and attributes\n    - [ ] Lookup a customer's segments\n    - [ ] Lookup messages sent to a customer\n    - [ ] Lookup a customer's activities\n  - [ ] **Beta API** (Campaigns)\n    - [ ] List campaigns\n    - [ ] Get a campaign\n    - [ ] Get campaign metrics\n    - [ ] Get campaign link metrics\n    - [ ] List campaign actions\n    - [ ] Get campaign message metadata\n    - [ ] Get a campaign action\n    - [ ] Update a campaign action\n    - [ ] Get campaign action metrics\n    - [ ] Get link metrics for an action\n  - [ ] **Beta API** (Newsletters)\n    - [ ] List newsletters\n    - [ ] Get a newsletter\n    - [ ] Get newsletter metrics\n    - [ ] Get newsletter link metrics\n    - [ ] List newsletter variants\n    - [ ] Get newsletter message metadata\n    - [ ] Get a newsletter variant\n    - [ ] Update a newsletter variant\n    - [ ] Get metrics for a variant\n    - [ ] Get newsletter variant link metrics\n  - [ ] **Beta API** (Segments)\n    - [ ] Create a manual segment\n    - [ ] List segments\n    - [ ] Get a segment\n    - [ ] Delete a segment\n    - [ ] Get a segment's dependencies\n    - [ ] Get a segment customer count\n    - [ ] List customers in a segment\n  - [ ] **Beta API** (Messages)\n    - [ ] List messages\n    - [ ] Get a message\n    - [ ] Get an archived message\n  - [ ] **Beta API** (Exports)\n    - [ ] List exports\n    - [ ] Get an export\n    - [ ] Download an export\n    - [ ] Export customer data\n    - [ ] Export information about deliveries\n  - [ ] **Beta API** (Activities)\n    - [ ] List activities\n  - [ ] **Beta API** (Collections)\n    - [x] Create a collection\n    - [ ] List your collections\n    - [ ] Lookup a collection\n    - [ ] Delete a collection\n    - [x] Update a collection\n    - [ ] Lookup collection contents\n    - [ ] Update the contents of a collection\n  - [ ] **Beta API** (Sender Identities)\n    - [ ] List sender identities\n    - [ ] Get a sender\n    - [ ] Get sender usage data\n  - [ ] **Beta API** (Reporting Webhooks)\n    - [ ] Create a reporting webhook\n    - [ ] List reporting webhooks\n    - [ ] Get a reporting webhook\n    - [ ] Update a webhook configuration\n    - [ ] Delete a reporting webhook\n    - [ ] Reporting webhook format\n  - [ ] **Beta API** (Broadcasts)\n    - [ ] List broadcasts\n    - [ ] Get a broadcast\n    - [ ] Get metrics for a broadcast\n    - [ ] Get broadcast link metrics\n    - [ ] List broadcast actions\n    - [ ] Get message metadata for a broadcast\n    - [ ] Get a broadcast action\n    - [ ] Update a broadcast action\n    - [ ] Get broadcast action metrics\n    - [ ] Get broadcast action link metrics\n    - [ ] Get broadcast triggers\n  - [ ] **Beta API** (Snippets)\n    - [ ] List snippets\n    - [ ] Update snippets\n    - [ ] Delete a snippet\n  - [ ] **Beta API** (Info)\n    - [ ] List IP addresses\n  \n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ccode\u003eBefore we get started: API client vs. JavaScript snippet\u003c/code\u003e\u003c/strong\u003e\u003c/summary\u003e\n\u003cbr/\u003e\n\nIt's helpful to know that everything (`Tracking API`) below can also be accomplished\nthrough the [Customer.io JavaScript snippet](https://customer.io/docs/api/#tag/trackJsOrBackend).\n\nIn many cases, using the JavaScript snippet will be easier to integrate with\nyour app, but there are several reasons why using the API client is useful:\n\n- You're not planning on triggering emails based on how customers interact with\n  your website (e.g. users who haven't visited the site in X days)\n- You're using the javascript snippet, but have a few events you'd like to\n  send from your backend system. They will work well together!\n- You'd rather not have another javascript snippet slowing down your frontend.\n  Our snippet is asynchronous (doesn't affect initial page load) and very small, but we understand.\n\nIn the end, the decision on whether to use the API client, or\nthe JavaScript snippet should be based on what works best for you.\nYou'll be able to integrate **fully** with [Customer.io](https://customer.io) with either approach.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ccode\u003eBasic Setup\u003c/code\u003e\u003c/strong\u003e\u003c/summary\u003e\n\u003cbr/\u003e\n\nCreate an instance of the client with your [Customer.io credentials](https://fly.customer.io/settings/api_credentials).\n\n```go\nclient, err := customerio.NewClient(\n    customerio.WithTrackingKey(os.Getenv(\"TRACKING_SITE_ID\"), os.Getenv(\"TRACKING_API_KEY\")),\n    customerio.WithRegion(customerio.RegionUS),\n)\n```\n\nYour account region—`RegionUS` or `RegionEU`—is optional. If you do not specify your region, \nwe assume that your account is based in the US (`RegionUS`). If your account is based in the \nEU and you do not provide the correct region, we'll route requests from the US to `RegionEU` accordingly, \nhowever this may cause data to be logged in the US.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ccode\u003eAdd or Update logged in customers\u003c/code\u003e\u003c/strong\u003e\u003c/summary\u003e\n\u003cbr/\u003e\n\nTracking data of logged in customers is a key part of [Customer.io](https://customer.io). In order to\nsend triggered emails, we must know the email address of the customer. You can\nalso specify any number of customer attributes which help tailor [Customer.io](https://customer.io) to your\nbusiness.\n\nAttributes you specify are useful in several ways:\n\n- As customer variables in your triggered emails. For instance, if you specify\n  the customer's name, you can personalize the triggered email by using it in the\n  subject or body.\n\n- As a way to filter who should receive a triggered email. For instance,\n  if you pass along the current subscription plan (free / basic / premium) for your customers, you can\n  set up triggers which are only sent to customers who have subscribed to a\n  particular plan (e.g. \"premium\").\n\nYou'll want to identify your customers when they sign up for your app and any time their\nkey information changes. This keeps [Customer.io](https://customer.io) up to date with your customer information.\n\n```go\n// Arguments\n// customerID (required) - a unique identifier string for this customers\n// attributes (required) - a ```map[string]interface{}``` of information about the customer. You can pass any\n//                         information that would be useful in your triggers. You\n//                         should at least pass in an email, and created_at timestamp.\n//                         your interface{} should be parsable as Json by 'encoding/json'.Marshal\n\nerr = client.UpdateCustomer(\"123\", map[string]interface{}{\n  \"created_at\": time.Now().Unix(),\n  \"email\":      \"bob@example.com\",\n  \"first_name\": \"Bob\",\n  \"plan\":       \"basic\",\n})\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ccode\u003eDeleting customers\u003c/code\u003e\u003c/strong\u003e\u003c/summary\u003e\n\u003cbr/\u003e\n\nDeleting a customer will remove them, and all their information from\n[Customer.io](https://customer.io). Note: if you're still sending data to [Customer.io](https://customer.io) via\nother means (such as the javascript snippet), the customer could be\nrecreated.\n\n```go\n// Arguments\n// customerID (required) - a unique identifier for the customer.  This\n//                          should be the same id you'd pass into the\n//                          `UpdateCustomer` command above.\n\nclient.DeleteCustomer(\"5\")\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ccode\u003eTracking a custom event\u003c/code\u003e\u003c/strong\u003e\u003c/summary\u003e\n\u003cbr/\u003e\n\nNow that you're identifying your customers with [Customer.io](https://customer.io), you can now send events like\n\"purchased\" or \"watchedIntroVideo\". These allow you to more specifically target your users\nwith automated emails, and track conversions when you're sending automated emails to\nencourage your customers to perform an action.\n\n```go\n// Arguments\n// customerID (required)  - the id of the customer who you want to associate with the event.\n// name (required)        - the name of the event you want to track.\n// timestamp (optional)   - used for sending events in the past\n// attributes (optional)  - any related information you'd like to attach to this\n//                          event, as a ```map[string]interface{}```. These attributes can be used in your triggers to control who should\n//                         receive the triggered email. You can set any number of data values.\n\nclient.NewEvent(\"5\", \"purchase\", time.Now().UTC(), map[string]interface{}{\n\"type\": \"socks\",\n\"price\": \"13.99\",\n})\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ccode\u003eTracking an Anonymous Event\u003c/code\u003e\u003c/strong\u003e\u003c/summary\u003e\n\u003cbr/\u003e\n\n[Anonymous events](https://learn.customer.io/recipes/anonymous-invite-emails.html) are\nalso supported. These are ideal for when you need to track an event for a\ncustomer which may not exist in your People list.\n\n```go\n// Arguments\n// name (required)            - the name of the event you want to track.\n// timestamp (optional)       - used for sending events in the past\n// attributes (optional)      - any related information you'd like to attach to this\n//                              event, as a ```map[string]interface{}```. These attributes can be used in your triggers to control who should\n//                              receive the triggered email. You can set any number of data values.\n\nclient.NewAnonymousEvent(\"invite\", time.Now().UTC(), map[string]interface{}{\n    \"first_name\": \"Alex\",\n    \"source\": \"OldApp\",\n})\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ccode\u003eAdding a device to a customer\u003c/code\u003e\u003c/strong\u003e\u003c/summary\u003e\n\u003cbr/\u003e\n\nIn order to send push notifications, we need customer device information.\n\n```go\n// Arguments\n// customerID (required)      - a unique identifier string for this customer\n// device.ID (required)       - a unique identifier string for this device\n// device.Platform (required) - the platform of the device, currently only accepts 'ios' and 'andriod'\n// device.LastUsed (optional) - the timestamp the device was last used\n\nclient.UpdateDevice(\"5\", \u0026customerio.Device{\n  ID:       \"1234567890\",\n  LastUsed: time.Now().UTC().Unix(),\n  Platform: customerio.PlatformIOs,\n})\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ccode\u003eDeleting devices\u003c/code\u003e\u003c/strong\u003e\u003c/summary\u003e\n\u003cbr/\u003e\n\nDeleting a device will remove it from the customers' device list in Customer.io.\n\n```go\n// Arguments\n// customerID (required) - the id of the customer the device you want to delete belongs to\n// deviceID (required)   - a unique identifier for the device.  This\n//                          should be the same id you'd pass into the\n//                          `UpdateDevice` command above\n\nclient.DeleteDevice(\"5\", \"1234567890\")\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ccode\u003eSend Transactional Messages\u003c/code\u003e\u003c/strong\u003e\u003c/summary\u003e\n\u003cbr/\u003e\n\nTo use the Customer.io [Transactional API](https://customer.io/docs/transactional-api), create an instance\nof the API client using an [app key](https://customer.io/docs/managing-credentials#app-api-keys).\n\nCreate a `SendEmailRequest` instance, and then use `SendEmail` to send your message.\n[Learn more about transactional messages and optional `SendEmailRequest` properties](https://customer.io/docs/transactional-api).\n\nYou can also send attachments with your message. Use `Attach` to encode attachments.\n\n```go\nimport \"github.com/mrz1836/go-customerio\"\n\nclient, err := customerio.NewClient(\n  customerio.WithAppKey(os.Getenv(\"APP_API_KEY\")),\n  customerio.WithRegion(customerio.RegionUS),\n)\n// TransactionalMessageId — the ID of the transactional message you want to send.\n// To                     — the email address of your recipients.\n// Identifiers            — contains the id of your recipient. If the id does not exist, Customer.io creates it.\n// MessageData            — contains properties that you want reference in your message using liquid.\n// Attach                 — a helper that encodes attachments to your message.\n\nrequest := client.SendEmailRequest{\n  To: \"person@example.com\",\n  TransactionalMessageID: \"3\",\n  MessageData: map[string]interface{}{\n    \"name\": \"Person\",\n    \"items\": map[string]interface{}{\n      \"name\": \"shoes\",\n      \"price\": \"59.99\",\n    },\n    \"products\": []interface{}{},\n  },\n  Identifiers: map[string]string{\n    \"id\": \"example1\",\n  },\n}\n\n// (optional) attach a file to your message.\nf, err := os.Open(\"receipt.pdf\")\nif err != nil {\n  fmt.Println(err)\n}\nrequest.Attach(\"receipt.pdf\", f)\n\nbody, err := client.SendEmail(context.Background(), \u0026request)\nif err != nil {\n  fmt.Println(err)\n}\n\nfmt.Println(body)\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ccode\u003eLibrary Deployment\u003c/code\u003e\u003c/strong\u003e\u003c/summary\u003e\n\u003cbr/\u003e\n\n[goreleaser](https://github.com/goreleaser/goreleaser) for easy binary or library deployment to GitHub and can be installed via: `brew install goreleaser`.\n\nThe [.goreleaser.yml](.goreleaser.yml) file is used to configure [goreleaser](https://github.com/goreleaser/goreleaser).\n\nUse `make release-snap` to create a snapshot version of the release, and finally `make release` to ship to production.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ccode\u003eMakefile Commands\u003c/code\u003e\u003c/strong\u003e\u003c/summary\u003e\n\u003cbr/\u003e\n\nView all `makefile` commands\n```shell script\nmake help\n```\n\nList of all current commands:\n```text\nall                  Runs multiple commands\nclean                Remove previous builds and any test cache data\nclean-mods           Remove all the Go mod cache\ncoverage             Shows the test coverage\ngodocs               Sync the latest tag with GoDocs\nhelp                 Show this help message\ninstall              Install the application\ninstall-go           Install the application (Using Native Go)\nlint                 Run the golangci-lint application (install if not found)\nrelease              Full production release (creates release in Github)\nrelease              Runs common.release then runs godocs\nrelease-snap         Test the full release (build binaries)\nrelease-test         Full production test release (everything except deploy)\nreplace-version      Replaces the version in HTML/JS (pre-deploy)\ntag                  Generate a new tag and push (tag version=0.0.0)\ntag-remove           Remove a tag if found (tag-remove version=0.0.0)\ntag-update           Update an existing tag to current commit (tag-update version=0.0.0)\ntest                 Runs vet, lint and ALL tests\ntest-ci              Runs all tests via CI (exports coverage)\ntest-ci-no-race      Runs all tests via CI (no race) (exports coverage)\ntest-ci-short        Runs unit tests via CI (exports coverage)\ntest-short           Runs vet, lint and tests (excludes integration tests)\nuninstall            Uninstall the application (and remove files)\nupdate-linter        Update the golangci-lint package (macOS only)\nvet                  Run the Go vet application\n```\n\u003c/details\u003e\n\n\u003cbr/\u003e\n\n## Examples \u0026 Tests\nAll unit tests and [examples](examples) run via [GitHub Actions](https://github.com/mrz1836/go-customerio/actions) and\nuses [Go version(s) 1.22.x](https://golang.org/doc/go1.22). View the [configuration file](.github/workflows/run-tests.yml).\n\nRun all tests (including integration tests)\n```shell script\nmake test\n```\n\nRun tests (excluding integration tests)\n```shell script\nmake test-short\n```\n\n\u003cbr/\u003e\n\n## Benchmarks\nRun the Go benchmarks:\n```shell script\nmake bench\n```\n\n\u003cbr/\u003e\n\n## Code Standards\nRead more about this Go project's [code standards](.github/CODE_STANDARDS.md).\n\n\u003cbr/\u003e\n\n## Usage\nCheckout all the [examples](examples)!\n\n\u003cbr/\u003e\n\n## Maintainers (of the Fork)\nThis is an \"unofficial fork\" of the [official library](https://github.com/customerio/go-customerio) and was \ncreated to enhance or improve missing functionality.\n\n| [\u003cimg src=\"https://github.com/mrz1836.png\" height=\"50\" alt=\"MrZ\" /\u003e](https://github.com/mrz1836) |\n|:------------------------------------------------------------------------------------------------:|\n|                                [MrZ](https://github.com/mrz1836)                                 |\n\n\u003cbr/\u003e\n\n## Contributing\n\nView the [contributing guidelines](.github/CONTRIBUTING.md) and follow the [code of conduct](.github/CODE_OF_CONDUCT.md).\n\n### How can I help?\nAll kinds of contributions are welcome :raised_hands:!\nThe most basic way to show your support is to star :star2: the project, or to raise issues :speech_balloon:.\nYou can also support this project by [becoming a sponsor on GitHub](https://github.com/sponsors/mrz1836) :clap:!\n\u003cbr/\u003e\n\n## License\n\n[![License](https://img.shields.io/github/license/mrz1836/go-customerio.svg?style=flat\u0026v=1)](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrz1836%2Fgo-customerio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrz1836%2Fgo-customerio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrz1836%2Fgo-customerio/lists"}