How to track newspaper/TV ad with Piwik


#1

Had a request from a client to help them shorten down the url for the ad they were going to put in a printed brochure plus a newspaper.

The url is ‘mywebsite.com -&nbspThis website is for sale! -&nbspmywebsite Resources and Information.’ but they wanted the regular home page to load and in the process record in Piwik the fact that their entry page was mywebsite.com/2012

I created the folder 2012 in the root, and within it the single file titled index.html containing the following code.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="robots" content="noindex", "nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="3;url=http://www.mywebsite.com">
<title>mydemo</title>
</head>

<body>

<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://www.mywebsite.com/piwik/" : "http://www.mywebsite.com/piwik/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
piwikTracker.setDocumentTitle(document.title);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://www.mywebsite.com/piwik/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->
<p>&nbsp;</p>

You should be automatically redirected to the <a href="http://www.mywebsite.com">mywebsite.com</a> homepage within 3 seconds.


</body>
</html>


  • Note that the part where it says you can change the number ‘3’ to however many seconds you want. You could also add a small logo/image to the page just for people to look at.

The 2 X winking smiley’s seems to be replacing the ; and ) in the code.

I also have a goal set up to check for the title of the redirecting index.html page (you can give it what ever title you wish)

Many thanks to Matt for his help in getting the solution sorted out.

Andrew