SlmGoogleAnalytics
SlmGoogleAnalytics copied to clipboard
CustomVariable overwrite key name
Allows CustomVariable key to be overwritten, this allows the user to add custom variables without the dimension as the key
@karlclement thanks for this feature and feature submit! I can only see custom variables with fixed names. Is there any documentation about the type of parameters you have implemented?
Furthermore I notice that the CS check does fail which is why the build is failing.
@juriansluiman My pleasure. Here is some documentation for you:
By default, CustomVariable will use the name dimension1
, 1
being the index provided. If you wish to specify a custom variable name, you can use:
$customVariable->setOverride(true)
Or you can pass in the true
as the last parameter when you instantiate the CustomVariable
:
$cv = new CustomVariable('1', 'Variable Name', 'Variable Value', self::SCOPE_PAGE_LEVEL, true )
It will then use the Variable Name
as the name of that variable instead of using the default dimension
. This allows you to set multiple custom variables, for example, if you wish to set the referrer on page view, you use the custom variable referrer
to set it in Google Analytics manually like so:
$cv = new CustomVariable('1', 'referrer', 'http://domain.com', self::SCOPE_PAGE_LEVEL, true )
Here is a link to Google's documentation on all the fields available: https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference
@juriansluiman I added documentation and made tests pass, good to go?
@juriansluiman ?