Custom Variable Help (js/ftl)

Hi all,
I’m trying to get a custom variable setup to track in piwik and having some difficulty (i’m new to all of this stuff and limited knowledge of js).

Basically i have a page ID being generated via JS somewhere in the heading area of the my page and stored in a variable called pageID.


var pageID = "${page.id?c}";

When i view the source, I can see that the value is set correct (var pageID = 525618);

So I wanted to reuse this variable in the footer of the page for piwik tracking. I used it like this:


_paq.push(['setCustomVariable', 1, 'pageid','pageID', 'visit']);

But this doesn’t actually work. When I view the source, the variable name shows up in the piwik code above…not it’s value of 525618.

Any help on what i can do? If i do console.log (pageID), it shows 525618.

Thank you.

use this instead (without quotes around your javascript variable):

_paq.push([‘setCustomVariable’, 1, ‘pageid’,pageID, ‘visit’]);