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

Visit dimension and Action dimension support #19

Open
karthik-hr opened this issue Jun 22, 2023 · 3 comments
Open

Visit dimension and Action dimension support #19

karthik-hr opened this issue Jun 22, 2023 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@karthik-hr
Copy link

Provide option for Visit Dimension and Action Dimension support

https://github.com/jonkoops/matomo-tracker/tree/main/packages/react#advanced-usage
Please checkout customDimensions key and usage in above package

@karthik-hr karthik-hr added the enhancement New feature or request label Jun 22, 2023
@donni106
Copy link
Owner

donni106 commented Jun 23, 2023

Hi, if I understand correctly, we should be able to send optional data easily, right? Viewing the API docs, I found dimensions at https://developer.matomo.org/api-reference/tracking-api#optional-user-info.

dimension[1-999] — A Custom Dimension value for a specific Custom Dimension ID 
(requires Matomo 2.15.1 + [Custom Dimensions plugin](https://plugins.matomo.org/CustomDimensions) 
see the [Custom Dimensions guide](https://matomo.org/docs/custom-dimensions/)). 
If Custom Dimension ID is 2 use dimension2=dimensionValue to send a value for this dimension. 
The configured Custom Dimension has to be in scope "Visit".

and at https://developer.matomo.org/api-reference/tracking-api#optional-action-info-measure-page-view-outlink-download-site-search

dimension[0-999] — A Custom Dimension value for a specific Custom Dimension ID 
(requires Matomo 2.15.1 + [Custom Dimensions plugin](https://plugins.matomo.org/CustomDimensions) 
see the [Custom Dimensions guide](https://matomo.org/docs/custom-dimensions/)). 
If Custom Dimension ID is 2 use dimension2=dimensionValue to send a value for this dimension. 
The configured Custom Dimension has to be in scope "Action".

You are already able to send custom user/action info with every action. See the following method for example for tracking actions:

/**
* Tracks actions
*
* Doc: https://developer.matomo.org/api-reference/tracking-api#recommended-parameters
*
* @param {Object} data -
* {String} `name` - The title of the action being tracked. It is possible to use slashes / to set one or several categories for this action. For example, Help / Feedback will create the Action Feedback in the category Help.
*
* {Object} `userInfo` - Optional data used for tracking different user info, see https://developer.matomo.org/api-reference/tracking-api#optional-user-info.
*/
trackAction({ name, userInfo = {} }) {
if (!name) throw new Error('Error: name is required.');
return this.track({ action_name: name, ...userInfo });
}

In the optional userInfo param you can set any value from the API docs. So the following example should work.

trackAction({ name: 'Foo', userInfo: { dimension2: 'Bar' } })

Please give it a try and tell us your experiences.

@donni106 donni106 added question Further information is requested and removed enhancement New feature or request labels Jun 23, 2023
@angelxmoreno
Copy link
Contributor

@karthik-hr were you able to resolve this?

@donni106
Copy link
Owner

@karthik-hr can you give a short update on this please?

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

No branches or pull requests

3 participants