Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CustomVariable overwrite key name #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

karlclement
Copy link
Contributor

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

@juriansluiman
Copy link
Owner

@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.

@karlclement
Copy link
Contributor Author

@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

…add custom variables without the dimension as the key

Minor fixes failed build

Minor spacing
@karlclement
Copy link
Contributor Author

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

@karlclement
Copy link
Contributor Author

@juriansluiman ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants