Created
January 28, 2025 17:36
-
-
Save steven-tey/9bef11aa3ba6bf9bdd7ec8a34333e8c1 to your computer and use it in GitHub Desktop.
Get links by tenantId and their analytics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const links = await dub.links.list({ | |
tenantId: "xxx" | |
}).then((res) => res.result) | |
// if you need all time stats, the links array should have `clicks`, `leads` and `sales` | |
// for a certain timeframe | |
const analytics = await Promise.all(links.map(async (link) => { | |
return await dub.analytics.retrieve({ | |
event: "composite", // to get clicks, leads, sales, and saleAmount | |
linkId: link.id, | |
start: "2024-01-01", | |
end: "2024-01-31", | |
}); | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment