Language URL stripper

Language URL stripper

Replace the language from the URL with a custom value

Configuration

OptionDescription
Pattern
Type: string
Required: True

Ininitalized with const regexp = new RegExp($pattern)

Match group
Type: string
Required: True

Used in: const value = regexp.match($pathname)[$matchGroup]

Property
Type: string
Required: True

Name of the event property we will store the matched value in

Replacement pattern
Type: string
Required: True

Initialized with new RegExp($pattern), leave empty to disable path cleanup.

Replacement key
Type: string
Required: True

Where to store the updated path. Keep as $pathname to override.

Replacement value
Type: string
Required: True

properties[key] = $pathname.replace(pattern, value)

Using our REST API you can create this transformation like so:

Terminal
# Create a new destination
curl --location 'https://us.i.posthog.com/api/environments/:project_id/hog_functions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <POSTHOG_PERSONAL_API_KEY>' \
--data '{
"type": "transformation",
"name": "Language URL stripper",
"inputs": {
"pattern": {
"value": ""
},
"matchGroup": {
"value": ""
},
"property": {
"value": ""
},
"replacePattern": {
"value": ""
},
"replaceKey": {
"value": ""
},
"replaceValue": {
"value": ""
}
},
"enabled": true,
"template_id": "plugin-language-url-splitter-app"
}'