Closed jrpub closed 5 years ago
It's a bug indeed and created a fix for it.
FYI: If you find more issues, please create them in https://github.com/matomo-org/tag-manager/issues ideally. Cheers
@tsteur
FYI: If you find more issues, please create them in https://github.com/matomo-org/tag-manager/issues ideally.
I guess this will happen more often now that MTM is a part of Matomo.
You should be able to easily move the issue to the tag-manager repo: https://help.github.com/articles/transferring-an-issue-to-another-repository/
👍 done
Tested, it works to validate the form, but however I don't understand something.
I expected the same behaviour as if I put {{ScrollVerticalPercentage}} in "Event actions", where the variable is replaced on the tracked website not in Matomo.
Once I save that, the form shows "0" (meaning that the variable is likely replaced immediately).
Where is it replaced immediately? In the create/edit form it still shows the variable name for me.
I tried again:
I entered the variable {{RandomNumber}} for instance, then I am clicking on "Update".
Then the form is just showing 0:
In the database, the value is stored as 0:
The eventValue is correctly sent to the API:
EDITED: a bit more information:
$parameters['eventValue']
is still correct at the entry of the function formatParameters
in Tag.php, but the returned parameters and $newParameters['eventValue']
contains 0.
private function formatParameters($tagType, $parameters)
{
$tagTemplate = $this->tagsProvider->getTag($tagType);
if (empty($tagTemplate)) {
throw new \Exception('Invalid tag type');
}
file_put_contents("test.txt", print_r($parameters, true)); // ADDED
$params = $tagTemplate->getParameters();
// we make sure to only save parameters that are defined in the tag template
$newParameters = [];
foreach ($params as $param) {
if (isset($parameters[$param->getName()])) {
$param->setValue($parameters[$param->getName()]);
$newParameters[$param->getName()] = $param->getValue();
} else {
// we need to set a value to make sure that if for example a value is required, we trigger an error
$param->setValue($param->getDefaultValue());
}
}
file_put_contents("test.txt", print_r($newParameters, true), FILE_APPEND); // ADDED
return $newParameters;
}
RESULTS:
more test.txt
Array
(
[matomoConfig] => {{Matomo Configuration}}
[trackingType] => event
[idGoal] =>
[eventCategory] => test
[eventAction] => test
[eventName] => test
[eventValue] => {{RandomNumber}}
)
Array
(
[matomoConfig] => {{Matomo Configuration}}
[trackingType] => event
[idGoal] =>
[eventCategory] => test
[eventAction] => test
[eventName] => test
[eventValue] => 0
)
Sorry about that, I just noticed I've only applied part of the patch and not all my changes I had. Fixed it in https://github.com/matomo-org/tag-manager/commit/478e05718cb33c13f23d70d9409bbbbb4c67c88b
Ah yes, much better! It works.
I can stop to debuging it myself :p
Many thanks!
Not fully solved yet!
"The event value can only include numeric values and variables." when publishing the new tags.
So sorry about that! See fix in https://github.com/matomo-org/tag-manager/pull/131 . Was very early this morning and must have forgotten to look at the tests (which I usually always do). Should be fixed now but will wait for tests to pass before merging.
Hi,
Sorry if this issue is not a bug. When I try to set a variable name as the value of an event in the tag manager, I have the error message:
Event Value: The value is not a number.
I tried with several variables (custom - for instance a constant - or a predefined one). Is this not supported or did I miss something? The weird thing is that there is the variable selector button near the "Event value", so I guess this is a supported feature.