Append Values to Custom Variables (instead of replace) Doable?

Is it possible to modify piwik to append values to custom variables instead of replacing them? That would be GOLDEN! I setup a custom variable called Social Action scope visit, and clicking a social link works and updates the record for the visitor. But as soon as the visitor clicks another social link, the value is replaced. I know that is normal with piwik.

So, basically if a visitor clicked both of these:

onclick: _paq.push([‘setCustomVariable’,3,‘Social Action’,‘Twitter Click’,‘visit’])
onclick: _paq.push([‘setCustomVariable’,3,‘Social Action’,‘Facebook Click’,‘visit’])

It will only show last value…

Social Action = Facebook Click

This would be GOLDEN:

Social Action = Twitter Click, Facebook Click

Really, I would imagine this be a very simple mod. Get current value, append (implode) new value (comma separated) and save.

Can anyone please point me to any information that would help me accomplish this? What file(s) / method(s) would I need to modify? I would be very grateful for any info!

Using 1.12 (just downgraded from 2.0 as it wasn’t working :frowning: )
Thank you

Well, I’ve managed to come up with a javascript solution to do this, and I figured I’d share it in case anyone else is interested in this ability to append values to custom variables. Not sure if this is the best solution, but it sure beats modifying piwik. And I’m no javascript expert, so if anyone has a better or cleaner way to do this, please share.


function addPiwikAction(index,name,value,scope)
{
	var cvar,cval;
	_paq.push([function(){cvar=this.getCustomVariable(index,scope);}]);
	if(cvar) // If there's an existing value
	{
		cval = cvar.toString().split(',');
		cval = cval.toString().replace(name+',','');
		if(cval.indexOf(value) === -1) // if the value doesn't already exist
		{ 
			cval = cval+','+value; 
		} 
	}
	else // Create the first value
	{
		cval=value;
	}
	_paq.push(['setCustomVariable',index,name,cval,scope]);
	_paq.push(['trackPageView']);
}

So if you click these two links in order:

Twitter Click |
Facebook Share

Your log for the visitor will show:

Social: Twitter Click,Facebook Share

Note: If you using the above function, make sure you don’t use the standard setCustomVariable for the same variable/scope like below, because it will replace any existing values for the var set by the function above.

Twitter Share Regular Piwik

What wasn’t working in 2.0-beta ? It is important to tell us so we can fix it for other users! thanks

Tried 2 b3 and b5. Campaigns werent being tracked in either. Visitor log worked in 2 b3 but was displaying label names and such instead of headings/icons, and in b5 visitor log showed empty rows, clicking evo icon gave errors. Seen others with similar reporting.

1.12 is working great so far.

At least now I can use some plugins… which I really don’t understand why the plugin options is so lacking. I mean there seems to be a lot of users in the piwik community, and being that piwik is the best alternative to data hungry ganalytics… I would think there would be a nice selection of plugins… updated… easy to find and use, hopefully soon. What I have noticed though is a lack of support for plugin developers it seems. Like the bottracker plugin author for example… doesnt have any doc to guide converting to new piwik, so has to spend much more time than necessary digging through what is avail, so surely that throws developers off from getting thier plugins working with 2.0.

Great plugins make a good product better. Imagine firefox without addons, iphone without apps, etc… I would suggest piwik team really throw in some support for developers. Find out what they need and give it to them. I believe a great selection of active/current plugins will make piwik much more successful.

I would think there would be a nice selection of plugins… updated… easy to find and use, hopefully soon.
Thanks for the suggestion. We fully agree! we are investing a lot in upgrading the Piwik source code to make it much easier to approach, well documented (we are starting work at http://developer.piwik.org/ ) and we have released the Plugins & Themes marketplace (http://plugins.piwik.org/ and http://themes.piwik.org/ )

We hope the open analytics platform Piwik 2.0 will be successful and popular with developers!
After its’ released we will definitely listen to developers and as much as possible try to help. For now we must focus on fixing 2.0-beta bugs and finishing the release.

I’m sure I speak for many if not all of us when I say that I’m looking forward to advancements of piwik. We all want it to successful, I’m sure.

While it’s great that you guys are focusing on finishing, if it were my call, I’d allocate more to developers now… so that when 2 is official, there’s not such a lag to get plugins out there. You might even get some great feedback for your final touches for piwik 2… the more eyes and minds involved the more that can be seen and realized.

I would start a small email list campaign now. Get developers subcribed. Get them looking into piwik 2. Ask for feedback or suggestions. Ask what they need. Let them know you’re there for them and encourage them to get started now. That’s what I’d do. That would be a small task I think, and could get the ball rolling.

That would be a small task I think, and could get the ball rolling.

we don’t have “extra” developers to assign to it… we are a small team that gets a lot done, only a handful of us :slight_smile:

it is no small task to ask & then listen & process & reply to feedback from dozens of people.
but of course we will do it just after the release. The feedback we get will be integrated in piwik 2.1 and 2.2 etc.

stay tuned!

The small task I was referring to was to setup a mailing list for developers to subscribe.

Either way, I’m sure you all have a lot of work going on and we all appreciate it. Looking forward to the official 2.0 release. :slight_smile: