Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add javascript API to trigger a goal trackGoal #778

Closed
mattab opened this issue Jun 10, 2009 · 19 comments
Closed

add javascript API to trigger a goal trackGoal #778

mattab opened this issue Jun 10, 2009 · 19 comments
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Milestone

Comments

@mattab
Copy link
Member

mattab commented Jun 10, 2009

This is the highest priority task to make Goal Tracking really useful; I was thinking of:```
piwikTracker.recordGoal( idGoal, customRevenue, customVars );


This requires, I believe, some minor updates to core/Tracker/*.php to set a new request type. 

Any other feedback?
@anonymous-matomo-user
Copy link

I think this will do well for Goals initially to get a basic functionality that lets us compete with and give my clients good advice on moving away from other platforms.

How do you imagine the customVars being handled (is that to say add in different options of the sale much like I showed you would we could track inside skype?)

I assume from looking at the referrer functions that the goals etc will also track to Search engines & keywords, direct traffic etc etc.

being that it will also now be in the tracker means it can also be used on dynamic url's etc right, not limited to finding a url for goal conversion.

Cheers
Marc

@robocoder
Copy link
Contributor

Keeping it simple, given the flexibility of customVars, I don't think we need separate customRevenue and customVars parameters.

Thus, the request from the client resembles those recorded for outlinks and downloads:

    piwik.php?idsite=WEBSITE_ID&goal=GOAL_ID&rand=RANDOM_NUMBER&redirect=0&data=JSON_STRING

@anonymous-matomo-user
Copy link

I tend to agree.

Doing what you mentiong there Vip, would then let something like this data be tracked also?

First Name
Last Name
Phone
Email
Date & Time of Booking
Confirmation No
Car Class (ECMR, SCAR etc)
Pickup Location
Dropoff Location
Pickup Date & Time
Dropoff Date & Time
Supplier (Europcar, Thrifty etc)
Total Booking Amount
Flight No

Assuming I could get all that data in a sale process (which I do post through)?

Talk Soon
Marc

@anonymous-matomo-user
Copy link

of course the only extra thing to say on that is....

so long as within customVars you can set the normal revenue that the current goal tracking uses (so that it can use the revenue as it would normally in the system.

Marc

@robocoder
Copy link
Contributor

The idea here is that if you omit the custom revenue in customVars, Piwik should fallback to using the revenue configured for that goal.

Example JavaScript:

  var myGoal = { 'FirstName' : 'Anthon' };
  myGoal.LastName = 'Pang';
  myGoal['revenue'] = 10; // override

This is JSON stringified to:

{"FirstName":"Anthon","LastName":"Pang","revenue":10}

Note: the custom data isn't being logged yet.

@anonymous-matomo-user
Copy link

Yep understood.

So.... :D

ETA on logging of revenue at tracker level :D One very excited tester eh

@mattab
Copy link
Member Author

mattab commented Jun 10, 2009

I agree that we could put the revenue in the customVars, but because revenue is the only "custom var" that is built-in the plugin - and will always be - I thought it would be clearer / easier to put it in the function signature. It would be optional though. For consistency we could rename it actually:```

piwikTracker.trackGoal( idGoal, [customRevenue], [customVars]);


does it make sense?

@robocoder
Copy link
Contributor

(In [1206]) refs #778 - implement trackGoal() on client-side

@robocoder
Copy link
Contributor

Ok.

piwik.php?idsite=WEBSITE_ID&goal=GOAL_ID&revenue=REVENUE&rand=RANDOM_NUMBER&redirect=0&data=JSON_STRING

@anonymous-matomo-user
Copy link

Hey Vipsoft,

Is this ready to be tested out now?

Talk Soon
Marc

@mattab
Copy link
Member Author

mattab commented Jun 13, 2009

(In [1214]) refs #778 adding the new Javascript Tracking API function: trackGoal to manually trigger a goal.
Example usage: piwikTracker.trackGoal(idgoal, [customData);

This can be used on external websites, simply give them the Piwik JS tracking tag, remove trackPageView and enableLinkTracking, and add the trackGoal call.

Marc, please let us know if you need more details to write the tutorial/documentation.

@mattab
Copy link
Member Author

mattab commented Jun 13, 2009

you can download piwik with this function at http://builds.piwik.org/piwik-0.4rc1.zip

@robocoder
Copy link
Contributor

(In [1216]) refs #778 - fix broken unit test and de-lint

@mattab
Copy link
Member Author

mattab commented Jun 13, 2009

the author of a book about Joomla and Virtuemart (ecommerce for Joomla) contacted us, and let us know that she would like to have a chapter about Piwik in the book, as well as documentation on how to track ecommerce using the goal tracking plugin, and the newly created trackGoal method - let's keep this in mind.

Marc, a simple ecommerce example would be great to have in the documentation use cases :-)

@anonymous-matomo-user
Copy link

Appears that in the changes done in rc1 the old tracker code being generated has been put in place (under show code for the sites)

Intentional?

Also when would they need that chapter in mind?

Also. Would it be possible to log both the original referrer that had the goal converted, and also the last one (I know you can set it in the settings file to be one or the other, but how about an option for both?)

Marc

@anonymous-matomo-user
Copy link

Unable to get the goal to track currently you can see live example of code on

http://www.theimalliance.com

the site ID & goal ID are correct.

Unsure how to make this track as you must also set a tracking url when setting the goal up (no option yet to say use in code tracking only, would be good to add that).

Would this be throwing it off?

Will try catch up with someone in the morning and give it another shot.

Thanks
Marc

@mattab
Copy link
Member Author

mattab commented Jun 15, 2009

Marc, shame on me, my link the release was wrong (I pointed to 0.4rc1 instead of 0.4.1-rc1)... here is the right link: http://builds.piwik.org/piwik-0.4.1-rc1.zip

sorry for the inconvenience, let me know how it goes!

@anonymous-matomo-user
Copy link

From initial checks its looking good on one domain.

Will roll it out over some more tomorrow.

though strange thing happened the updates Matt have stopped SearchEnginePosition plugin working.

Marc

@mattab
Copy link
Member Author

mattab commented Jun 25, 2009

seems to work fine - updated the doc on http://piwik.org/docs/javascript-tracking/

@mattab mattab added this to the Piwik 0.4.1 milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Projects
None yet
Development

No branches or pull requests

3 participants