Seamlink is a lightweight, SEO-friendly link tracking middleware for Fiber web framework. Track outbound clicks and referral sources without compromising SEO rankings or user experience.
- 🔗 SEO-friendly outbound link tracking
- 📊 Referrer source tracking
- 🚀 Zero impact on page load performance
- 🎯 Automatic script injection
- 🛡️ Domain exclusion support
- 📱 User agent tracking
- ⏱️ Timestamp recording
- 🔄 Non-blocking async tracking
- 💫 Client-side navigation preservation
This middleware supports Fiber v2.
go get -u github.com/gofiber/fiber/v2
go get -u github.com/streamerd/seamlink
seamlink.New(config ...seamlink.SeamlinkConfig) fiber.Handler
Property | Type | Description | Default |
---|---|---|---|
StoreLinkClick | func(SeamlinkClick) error |
Callback function for outbound click events | nil |
StorePageVisit | func(PageVisit) error |
Callback function for page visit events | nil |
ExcludeDomains | []string |
List of domains to exclude from tracking | [] |
type SeamlinkClick struct {
URL string `json:"url"`
Referrer string `json:"referrer"`
UserAgent string `json:"userAgent"`
Timestamp time.Time `json:"timestamp"`
}
type PageVisit struct {
URL string `json:"url"`
Referrer string `json:"referrer"`
UserAgent string `json:"userAgent"`
Timestamp time.Time `json:"timestamp"`
}
package main
import (
"fmt"
"log"
"github.com/gofiber/fiber/v2"
"github.com/streamerd/seamlink"
)
func main() {
app := fiber.New()
// Initialize Seamlink middleware
app.Use(seamlink.New(seamlink.SeamlinkConfig{
StoreLinkClick: func(click seamlink.SeamlinkClick) error {
fmt.Printf("🔗 Outbound click: %s (from: %s)\n", click.URL, click.Referrer)
return nil
},
StorePageVisit: func(visit seamlink.PageVisit) error {
fmt.Printf("👋 New visit: Came from %s to %s\n", visit.Referrer, visit.URL)
return nil
},
ExcludeDomains: []string{"internal.example.com"},
}))
// Serve your content
app.Get("/", func(c *fiber.Ctx) error {
return c.Type("html").SendString(`
<!DOCTYPE html>
<html>
<head><title>Seamlink Demo</title></head>
<body>
<a href="https://github.com">GitHub</a>
</body>
</html>
`)
})
log.Fatal(app.Listen(":3000"))
}
package main
import (
"github.com/gofiber/fiber/v2"
"github.com/streamerd/seamlink"
"gorm.io/gorm"
)
type ClickEvent struct {
gorm.Model
URL string
Referrer string
UserAgent string
}
func main() {
app := fiber.New()
db := initDatabase() // Your database initialization
app.Use(seamlink.New(seamlink.SeamlinkConfig{
StoreLinkClick: func(click seamlink.SeamlinkClick) error {
return db.Create(&ClickEvent{
URL: click.URL,
Referrer: click.Referrer,
UserAgent: click.UserAgent,
}).Error
},
ExcludeDomains: []string{"internal.example.com"},
}))
// Your routes here...
}
- Script Injection: Seamlink automatically injects a lightweight tracking script before the closing
</body>
tag - Click Tracking: Captures outbound link clicks using event listeners
- Source Tracking: Records referrer information when users visit your site
- Async Processing: Uses
fetch
API to send tracking data without blocking navigation - SEO Preservation: Maintains original link structures without redirects
- 🎯 Use domain exclusion for internal links
- 📊 Implement proper error handling in storage callbacks
- 🔒 Consider privacy regulations when storing user data
- 💾 Use appropriate database indexes for high-traffic scenarios
- 🚀 Keep storage callbacks lightweight to prevent blocking
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -am 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License.
- Fiber Web Framework
- Inspired by various analytics solutions while prioritizing SEO