b. My site is running on wordpress self-hosted and I am using a redirection plugin so that I use abc.com/affiliatedef as the landing page in the above ad, and the traffic arriving on abc.com/affiliatedef gets redirected by this plugin to affiliate.def.com. The plugin works fine, but the problem is that piwik does not record any activity when you arrive on abc.com/affiliatedef and immediately get redirected to affiliate.def.com. My guess is that because the redirection takes place before the piwik code is loaded, it does not get the hint about the traffic.
Solution of either of the above will be highly appreciated.
Without having control on website B and C , you need to define the href of your add to a redirection page on website A.
So, let’s see your second question.
Knowing which plugin could help… you should not choose one writing to .htaccess or generating it dynamically. You should choose a plugin using a php page and header messages for redirection.
That’s the right way to do but…
You’re right, if you are using htaccess to redirect, there is no way to make it.
BUT, if you use a php script, then the solution is:
I am testing two different wordpress plugins. One is “WinkPress Affiliate Links Manager” by WinkPress WordPress Blog | Compete Themes , while the other is “Custom Field Redirect Mod: Link Custom Field” by Nathan Rice WordPress Plugins
You can download them from these URLs as I am not allowed to attach zip files to this message.
I am not sure exactly what approach they are taking, htaccess or otherwise.
In piwik I have set a goal to track all outgoing traffic to Yahoo.com
If you click on the first post’s heading “Hello Yahoo”, it redirects to Yahoo through “Custom Field Redirect Mod” but piwik does not track the activity and the goal does not update.
If you click on the link “Yahoo Goal Working”, it takes you to Yahoo and the piwik goal is updated. However, this link is just a regular html link embedded in the post content.
using “Custom Field Redirect Mod: Link Custom Field” should work well, if you use the PHP Piwik api instead of the regular JS tracking code.
you have to add the php code before the redirection happens. The plugin uses
The other one seems better to me though. It uses internal wordpress function “redirect(url,responsecode)”.
This way, you can first trigger goal using php, then let the page load and the plugin redirect to your affiliate.
This will work for both on page and off page links (ie banner on other sites).
The other one seems better to me though. It also uses internal wordpress function “redirect(url,responsecode)”. But it doesn’t uses custom fields.You could then insert the PHP Piwik api before the redirection to trigger goal.
The hack should be made before line 413 in file /affiliate-links-manager/walm.php.
<?php
$piwikTracker = new PiwikTracker( $idSite = {$IDSITE} );
// You can manually set the visitor details (resolution, time, plugins, etc.)
// See all other ->set* functions available in the PiwikTracker.php file
$piwikTracker->setResolution(1600, 1400);
// Sends Tracker request via http
$piwikTracker->doTrackPageView('Document title of current page view');
// You can also track Goal conversions
$piwikTracker->doTrackGoal($idGoal = 1, $revenue = 42);
?>
Thank you so much for the help. So far so good. I am able to redirect the traffic to the redirect url, and track the page views under the Pages tab, as well as track the goal and its revenue value hardcoded in:
Pass the goal dynamically so that each page can have its own goal and goal value, either entered in custom fields, or passed in the url like www.mysite.com/pagetoyahoo/?idGoal=1&revenue=20
If we can use the custom field option, then assuming I am using a custom field “mygoal” and a custom field “mygoalrevenue”, then how can I bring those values in this:
$piwikTracker->doTrackGoal($idGoal = mygoal, $revenue = mygoalrevenue);
I modified
$piwikTracker->doTrackPageView(‘Document title of current page view’);
to
$piwikTracker->doTrackPageView($documentTitle);
but it reports it as “Page Name not defined” under the Page Titles tab.
Pass the goal dynamically so that each page can have its own goal and goal value, either entered in custom fields, or passed in the url like[/quote]
To use custom fields, then use the plugin “Custom Field Redirect” !
First, create a category for theses articles (ads etc) ie “Affiliate”. You will then put all redirection articles to affiliate links in this cat. Additionaly, you can remove this cat from the main page and/or from category list in you blog. Wordpress documentation can help you on this.
Second, create a post in this cat. And define 3 custom fields:
redirect → URL TO AFFILIATE
myGoal → AFFILIATE NAME
myGoalRevenue → REVENUE
$idPost = get_the_ID(); // this retreives the ID of the post
$myGoal=get_post_meta($idPost, "myGoal", true);
$myGoalRevenue=get_post_meta($idPost, "myGoalRevenue", true);
then simply set them in the piwik tracker as follow:
[quote=raza]
2. I modified
$piwikTracker->doTrackPageView(‘Document title of current page view’);
to
$piwikTracker->doTrackPageView($documentTitle);
but it reports it as “Page Name not defined” under the Page Titles tab.[/quote]