ShortURL v2.0.0
Short URL v2.0.0
New Features
- Added referer URL tracking options
- Added device type tracking options
- Added functionality to set the tracking options for individual short URLs.
- Added functionality to set the redirect status code for individual short URLs
- Added a
ShortURLVisited
event. - Added
trackingEnabled()
helper method - Added
trackingFields()
helper method
Added referer URL tracking options (#26)
There is now a new tracking option for the short URLs that allows you to track the referer URL of the visitor. For example, if the short URL is placed on a web page with URL ``` https://domain.com/page-name ```, that URL will be recorded if the referer URL tracking is enabled.If you want to override the default config option of whether if referer URL tracking is enabled or not when creating a shortened URL, you can use the ->trackRefererURL()
method.
The example below shows how to enable referer URL tracking for the URL and override the default config variable:
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
$shortURLObject = $builder->destinationUrl('https://destination.com')->trackVisits()->trackRefererURL()->make();
Added device type tracking options (#27)
There is now a new tracking option for the short URLs that allows you to track the device type of the visitor. There are four possibilities of device type: ``` mobile ```, ``` desktop ```, ``` tablet ```, ``` robot ```. This can be particularly useful for analytical purposes.If you want to override the default config option of whether if device type tracking is enabled or not when creating a shortened URL, you can use the ->trackDeviceType()
method.
The example below shows how to enable device type tracking for the URL and override the default config variable:
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
$shortURLObject = $builder->destinationUrl('https://destination.com')->trackVisits()->trackDeviceType()->make();
Added functionality to set the tracking options for individual short URLs (#29)
Up until now, the tracking options were set in the config and affected all new and existing short URLs. In this release, the tracking options in the config are now used for defining the defaults. These values can now be overridden when creating your short URLs.Updating the tracking options in the config now won't affect the new short URLs that are created.
The example below shows how to enable IP address tracking for the URL and override the default config variable:
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
$shortURLObject = $builder->destinationUrl('https://destination.com')->trackVisits()->trackIPAddress()->make();
Learn more about setting the tracking options in the README.
Added functionality to set the redirect status code for individual short URLs (#25)
Up until now, all short URLs have redirected (if using the package's provided controller) with a 301 HTTP status code. But, this can now be overridden when building the shortened URL using the ``` ->redirectStatusCode() ``` method.The example below shows how to create a shortened URL with a redirect HTTP status code of 302:
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
$shortURLObject = $builder->destinationUrl('http://destination.com')->redirectStatusCode(302)->make();
Added a ShortURLVisited
event (#24)
Each time a short URL is visited, the following event is fired that can be listened on:
AshAllenDesign\ShortURL\Events\ShortURLVisited
This is useful for if you want to trigger some code via listeners whenever a short URL is visited without needing to override the package's provided controller.
Added trackingEnabled()
helper method (#30)
To check if tracking is enabled for a short URL, you can use the ->trackingEnabled() method. It will return true if tracking is enabled, and false if not.
The following example shows how to check if a short URL has tracking enabled:
$shortURL = \AshAllenDesign\ShortURL\Models\ShortURL::first();
$shortURL->trackingEnabled();
Added trackingFields()
helper method (#30)
To check which fields are enabled for tracking for a short URL, you can use the ->trackingFields() method. It will return an array with the names of each field that is currently enabled for tracking.
The following example shows how to get an array of all tracking-enabled fields for a short URL:
$shortURL = \AshAllenDesign\ShortURL\Models\ShortURL::first();
$shortURL->trackingFields();