Opened 3 years ago

Closed 23 months ago

Last modified 22 months ago

#2222 closed Task (fixed)

Paypal tracking: Tracking API improvements & how to

Reported by: matt Owned by:
Priority: normal Milestone: 1.x - Piwik 1.x
Component: Documentation Keywords:
Cc: Sensitive: no

Description

See post in: http://forum.piwik.org/read.php?2,73977

I think we need to:

  • allow tracking by visitor ID, ie. the Tracking API should accept the visitor ID as a parameter, and use this to match the visitor (bypassing existing matching algorithm using IP etc)
  • JS API should have a getter for the referer cookie _pk_ref
  • Tracking API should have a parameter/new PiwikTracker function to set the referer for conversion attribution

Then we can also come up with a "How to" for tracking on Paypal. Of course these features will be useful for many other similar use cases.

Change History (15)

comment:1 Changed 3 years ago by matt (mattab)

(In [4350]) PiwikTracker

  • doc improvements
  • adding stubs for upcoming functionnality in Refs #2222
  • Refs #2172 PiwikTracker.java will need a few new functions when this work is finalized (will ping you when new API is final)

comment:2 Changed 3 years ago by matheweis

I too would be very interested in this use case; I stumbled across the forum post looking for exactly this. This would be extremely useful for getting very accurate associations between referrals and actual purchases!

I think that (for at least this specific use case), you would need to make use of PayPal's custom field to pass the visitor ID through IPN (Since only PayPal, and not the actual visitor, will pass data through IPN)

See:

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables#id08A6HH00W2J

comment:3 Changed 3 years ago by matt (mattab)

(In [4369]) Refs #2222 Implementing Visitor ID forced request, so that we can log, after the fact, a page/goal/action to the latest visit of a given visitor ID (useful for example to trigger goal conversions that were missed by the JS beacon...)
Had to add another index on the log_visit table unfortunately, to ensure reasonnably fast lookup on the idvisitor, even though this index will very rarely get used (never if you don't use the tracking API with setVisitorId()...)

comment:4 Changed 3 years ago by matt (mattab)

(In [4378]) Fixes #2168

  • Now crediting the right referrer for any goal conversion
  • Referrer URLs, timestamp, and Campaign name & keyword (parsed from the landing page URL) are now stored in a first party cookie (JSON encoded)
  • Added getters to the piwik.js to allow passing the values from the client, to store for later use in the PHP/Java Tracking API (paypal use case)
  • Added integration tests and basic JS tests

Refs #2172

  • Added a new API function: setAttributionInfo( $jsonEncoded ) which accepts JSON encoded array of 4 values (see implementation for details what to do with these values)
  • 2 new parameters are: _rcn and _rck to pass to piwik the campaign name and campaign keyword that will be creditted for the Goal conversion (if a goal is converted)
  • Also renamed setUrlReferer to setUrlReferrer -- Important that all public facing APIs use the proper writing

Refs #2222 Accurate Paypal tracking (or any other third party "after the fact" Goal conversion): implementation is now done, we must write some kind of guide and test

comment:5 Changed 3 years ago by matt (mattab)

matheweis, I think you can now try and get this to work. Here is a proposal / pseudo code:

  • before user leave your site to go to Paypal, call the following JS functions:
    • visitorId = piwikTracker.getVisitorId();
    • attributionInfo = JSON2.stringify(piwikTracker.getAttributionInfo());
  • store these values in a database or similar
  • then when Paypal call you back via IPN
    • use the PHP Tracking API to record the conversion
    • you must call the following functions at least to credit the right visit with the right referrer information
      • $tracker->setVisitorId( $visitorId ); which you stored earlier
      • $tracker->setAttributionInfo( $attributionJsonEncoded ); which you stored earlier
      • $tracker->setTokenAuth( $your_superUser_token_auth ); see http://piwik.org/faq/general/#faq_114
      • $tracker->doTrackGoal($idGoal, $revenue);

Then, Piwik will record, for the visit that was redirected to Paypal, the Goal conversion, making sure the Referrer (search engine, or website) or the Campaign (and keyword) used to reach the site in the first place, are credited for this goal conversion.

It would be great if you could give it a try and report if it is working :)

comment:6 Changed 3 years ago by matt (mattab)

matheweis, now is a good time to help with the Paypal stuff if you can :) PLease see my post in the forum: http://forum.piwik.org/read.php?2,73977,page=1#msg-74946 and if you can test it and report, it would be great thanks!

comment:7 Changed 3 years ago by morrack

After implementing this and running it for several days, I can confirm that it's working. Thanks Matt!

comment:8 Changed 3 years ago by matt (mattab)

Thanks for your patience and help in getting this to work nicely!

Do you think you would be able to write a short, practical how to to get Paypal tracking work for other Piwik users? it would be great. I will then write a documentation about campaign tracking and to explain attribution in general.

comment:9 Changed 3 years ago by morrack

Sure thing. I'll try to work on that this week.

comment:10 Changed 3 years ago by matt (mattab)

  • Milestone changed from 1.x - Piwik 1.x to 1.5 - Piwik 1.5
  • Priority changed from major to critical
  • Summary changed from Paypal tracking: Tracking API improvements required to Paypal tracking: Tracking API improvements & how to

comment:11 Changed 3 years ago by morrack

Basic how to guide posted in forum: http://forum.piwik.org/read.php?2,76296

comment:12 Changed 3 years ago by matt (mattab)

  • Component changed from Core to Documentation
  • Milestone changed from 1.5 - Piwik 1.5 to 1.x - Piwik 1.x
  • Priority changed from critical to normal
  • Type changed from New feature to Task

Thanks morrack, very appreciated! Maybe, we can wait a few weeks see if the post gets any feedback, and then turn it into some kind of official How to for piwik.org/docs/ ?

comment:13 Changed 3 years ago by matt (mattab)

When we put this tutorial online as an "official doc", we could also write a section about "How to record recurrent payments / conversions using Piwik" which would explain how to track revenue from monthly memberships, and still credit the money to the initial referrer that brought in the visitor, credit the right keyword/country/etc.

comment:14 Changed 23 months ago by matt (mattab)

  • Resolution set to fixed
  • Status changed from new to closed

comment:15 Changed 22 months ago by parisbonbon

Note: See TracTickets for help on using tickets.