Manage Matomo tag manager using Tagmanger APIs

@Lukas
Hi Everyone? I am creating container, tags and triggers in Matomo tag-manager section using tag-manager APIs. TagManager.addContainerTrigger giving following error.

"Conditions: "Conditions" has to be an array."

Here is the API.

http://localhost/matomo/index.php?module=API&method=TagManager.addContainerTrigger&idSite=2&idContainer=h4bJambk&idContainerVersion=84&type=Scroll%20Reach&name=ScrollReach1&parameters=[1,50]&conditions=[]&format=JSON&token_auth=8f0b4d544205572365ba9910e1cebb4a

Here is the screenshot of manually created trigger for 50% page scroll.

Please help me to create trigger. Thanks!

I am not expert on that… But for me, in HTTP, if you want to create an array, you should do: ...&arr=something&arr=somethingelse&arr=moredatainarray&...

Hi,

The UI is using exactly this API. So just check your browsers developer tool when you click save and you will see the exact request and can modify it to your needs.

Keep in mind that the conditions are sent as form data.

Hi @Lukas and @heurteph-ei Thanks for help. It is working fine now. Able to create triggers through API but unable to set it values i.e., in case of ScrollReach I am unable to set value 25 for vertical-percentage. Please have a look at attached screenshot.

Here is my API.

http://localhost/matomo/index.php?module=API&method=TagManager.addContainerTrigger&idSite=2&idContainer=h4bJambk&idContainerVersion=83&type=ScrollReach&name=5&parameters=1&parameters=25&format=JSON&token_auth=8f0b4d544205572365ba9910e1cebb4a

Here is the screenshot of output.

On my side I have a POST with parameters in the form data (not in the URL):

parameters[scrollType]	"verticalpercentage"
parameters[pixels]	"1"
parameters[percentage]	"25"
token_auth	"anonymous"
force_api_session	"1"

Recall:

Also (I don’t know if this has an impact or not), maybe check the idContainerVersion (=83) is the good one…

1 Like

Thanks @heurteph-ei I will try it with post method. may be it will work using Post method instead of get method.

Also both Firefox and Chrome allow you to copy a request as a curl command, which might help with reproducing the request.