A/B Testing & visit count

I have an A/B testing system (a RoR gem named split) that redirects the visitor (302) on either the page A or the page B by tossing a 50/50 coin. This systems has its own basic stats, which says that our visits are equally distributed between A and B.

We are tracking our pages with Piwik, to be able to retrieve more useful informations about our visits, but we encountered a serious issue : Piwik counts more than twice visits on the B page than on the A page.

Does anyone have any idea about why I have 2x more visits on B page in Piwik, when split gives me equal redirect counts ?

  • Is it the redirect 302 that is generating more visits ? (piwik tracking should not be loaded before the redirection, so I don’t think so)
  • Or it is my Piwik API requests that are badly crafted ? (That is way much more possible)

Here is the Piwik API request details :

  • I use the Piwik API to retreive the stats with the method VisitsSummary.get

  • The pages are named :

    • Page A : http://my_domain.com/my_page
    • Page B : http://my_domain.com/my_page-2
  • I crafted 2 segments to retrieve the stats of both pages :

    • Segment A : segment=pageUrl==http://my_domain.com/my_page,pageUrl=@http://my_domain.com/my_page?
    • Segment B : segment=pageUrl==http://my_domain.com/my_page-2,pageUrl=@http://my_domain.com/my_page-2?
  • Example of a full API request, for page B : http://piwik.seniormedia.fr/?module=API&format=JSON&token_auth=xxx&method=VisitsSummary.get&idSite=1&period=day&date=2016-02-15,2016-02-15&segment=pageUrl==http://my_domain.com/my_page-2,pageUrl=@http://my_domain.com/my_page-2?

Any help will be welcomed.

1 Like

Hi there, make sure you URL encode the segment values. Ie. http://my_domain.com/my_page-2 should be URL encoded.

The URLs are always encoded in my PiwikConnector class, which manages all my API requests. So I’m pretty sure this is not part of my problem.

We’ve managed to find out that some of our URLs are formatted with a \ just before the ? for GET arguments (like this : @http://my_domain.com/my_page-2/?), so I’ve changed my segments to take that into account. It has corrected the unbalance between both versions’s stats.

Thanks for your help anyway :wink:


We have released a plugin that works on top of Piwik to run A/B Tests, Split Tests, Experiments see http://www.ab-tests.net/ . A full list of features is mentioned on the Marketplace at https://plugins.piwik.org/AbTesting

It lets you easily run experiments on websites, servers, apps and in campaigns and has lots of features to customize your experiment and to define your success and your expectations for an experiment to increases your sales, revenue, conversions, pageviews, and more.

More docs are available at: User Guides, FAQ, Developer docs