electerious/Ackee

Add documentation "Rewrite URLs"

Offen

#163 geöffnet am 18.09.2020

 (0 Kommentare) (1 Reaktion) (0 zugewiesene Personen)JavaScript (386 Forks)github user discovery
help wanted

Repository-Metriken

Stars
 (4.692 Sterne)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

It's possible to modify URLs before sending them to Ackee. This allows you to…

…remove private data from URLs …remove parameters you don't care about …add a path when your navigation state is managed by your app (React) instead of being visible in the URL

It would be cool if someone could write a documentation about how to modify URLs. It's not 100% Ackee related as modifying URLs happens outside of ackee-tracker.

Here's an example:

  1. Get default attributes
const attributes = ackeeTracker.attributes()
// or
const attributes = ackeeTracker.attributes(true)
  1. Adjust the attributes

Ackee uses window.location.href for the siteLocation. You can simply replace this value and provide a custom URL. This allows you to remove unnecessary parameters. You can also transform a state-based navigation into a readable URL.

const customAttributes = {
	...attributes,
	siteLocation: removeParameters(window.location.href),
}
  1. Create an instance and track the visit
const instance = ackeeTracker.create({
	server: 'https://example.com',
	domainId: 'hd11f820-68a1-11e6-8047-79c0c2d9bce0'
})

instance.record(customAttributes)

This is related to #76 and #113

Contributor Guide