Where I must paste my Custom Variable line code?:S


#1

Pleeease… help me, I confused
In which file I must paste my test variable

piwikTracker.setCustomVariable(1,“test_name”,“test_value”,“visit” ) ;


(Matthieu Aubry) #2

you can paste this code in your javascript tracking code, see: JavaScript Tracking Client: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3

or see also: Using Custom Variables in Piwik (Tutorial) - Analytics Platform - Matomo


#3

Thanks!
Now I try for test paste next line in track code:

_paq.push([‘setCustomVariable’, 1, ‘Category’, ‘Sports’, ‘page’]);

and it’s working good!!! =) I’m glad =)

Next… I try paste from here Using Custom Variables in Piwik (Tutorial) - Analytics Platform - Matomo
this line with PHP

_paq.push([‘setCustomVariable’, 1, “VisitorType”, “<?php if ( is_user_logged_in() ) {echo 'Member';} else {echo 'Not Member';} ?>”, “visit”);

As a result, he told me the value showed a line of code to PHP <?php if ( is_user_logged_in() ) {echo 'Member';} else {echo 'Not Member';} ?>
Maybe I misunderstood how to insert code in the PHP?


#4

And WHY? in one tutorial line code begin : piwikTracker.setCustomVariable
another _paq.push([‘setCustomVariable’,

what different?