SlmGoogleAnalytics icon indicating copy to clipboard operation
SlmGoogleAnalytics copied to clipboard

CustomVariable overwrite key name

Open karlclement opened this issue 10 years ago • 4 comments

Allows CustomVariable key to be overwritten, this allows the user to add custom variables without the dimension as the key

karlclement avatar Jul 21 '14 18:07 karlclement

@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 avatar Jul 23 '14 20:07 juriansluiman

@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

karlclement avatar Aug 01 '14 00:08 karlclement

@juriansluiman I added documentation and made tests pass, good to go?

karlclement avatar Aug 22 '14 19:08 karlclement

@juriansluiman ?

karlclement avatar Sep 16 '14 13:09 karlclement