juenPedro
(Juen Pedro)
August 9, 2021, 9:29am
1
Hello,
I am running an affiliate website with offers. On that affiliate website i am running Matomo Analytics.
What is do is this.
If a user is clicking on a affiliate link i send the visitor_id with this link.
example: https://www.externaldomain.com?ref=REFCODE&subid=MATOMO_VISITORID
When they purchase the offer the externaldomain gives on there thankyoupage an GET/POST to my url.
https://www.mydomain.com/tracking/tracking.php?commission=15.20&subid=MATOMO_VISITORID
What is do on this tracking.php in the Matomo trackingcode is this:
_paq.push([‘trackGoal’, 2, <?php echo $commission; ?>]);
_paq.push([‘visitor_id’, <?php echo $subid; ?>]); //this one seems it’s not working.
My question is: How can i trackGoal been set for a specific MATOMO_VISITORID
juenPedro
(Juen Pedro)
August 11, 2021, 9:01am
2
Since I don’t have a response yet, I’ll describe it differently.
The trackGoal goes through a server request. The information what I have is this:
Goal_ID
Commission
Visitor_ID
Which tracking code should I use to measure goals and connect it to a visitor.
juenPedro
(Juen Pedro)
August 11, 2021, 12:30pm
4
Philippe thanks for your reply!
I’ve made a image to make the request clear.
The code i am using is
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
window._paq.push(['trackGoal', 2, <?php echo $commission; ?>]);
window._paq.push(['setUserId', <?php echo $subid; ?>]);
(function() {
var u="//matomo.domain.nl/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
ON tracking.php i need to setGoal and connect it to a userID
On page 1 (the one before going to awin.com
), do you set the same user ID?
So do you have the code:
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
_paq.push(['setUserId', <?php echo $subid; ?>]);
(function() {
var u="//matomo.domain.nl/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
juenPedro
(Juen Pedro)
August 11, 2021, 1:12pm
6
No i am not doing that. $subid is the userID from the cookie (_pk_id.1.1763)
the userId should be constant. If not, Matomo won’t consider it is the same user…
juenPedro
(Juen Pedro)
August 12, 2021, 8:36am
8
The userId is constant now and this is working.
The tracking.php is requested by a server (from awin.com )
On tracking.php is this trackingcode:
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
_paq.push(['trackGoal', 2, <?php echo $commission; ?>]);
_paq.push(['setUserId', <?php echo $subid; ?>]);
(function() {
var u="//matomo.domain.nl/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
The conversions aren’t logged by Matomo. Doe i need to change anything because the request is from a server?
Do you have a screenshot of the detailed visit log of a user (who reached the goal)?
juenPedro
(Juen Pedro)
August 12, 2021, 11:23am
10
Goals are zero…Matomo doesn’t tracking these goals properly
If i do it manualy the goal has been tracked! It’s working with the right commission and the right user.
The problem is that the page is visited by a server. And then the goal isn’t tracked.
Is it a server call or a JavaScript-API call
On your code examples, there is only JavaScript -API calls…
juenPedro
(Juen Pedro)
August 12, 2021, 11:36am
12
Hi Philippe,
Thanks for your fast reply!
It is a server call that woud be the reason ithink. do you know what i need to change?
Are you sure the server reach your matomo server? (do you have a log somewhere?)
I suppose you use the HTTP API: Tracking HTTP API: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v4
Then try to use the url
parameter.
Or else maybe you can configure the measurable:
(Note: there is also some excluded IPs in these settings)
juenPedro
(Juen Pedro)
August 12, 2021, 12:23pm
14
Thanks! i need to wait for a conversion now
I watched this for HTTP API https://www.youtube.com/watch?v=bYly4q6VOkA