Last active
September 2, 2016 21:15
-
-
Save clarkwinkelmann/fa56404d69b36ed5f67a561fbd41d5ce to your computer and use it in GitHub Desktop.
Javascript redirect and Piwik tracking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Redirecting to {{ page.title }}...</title> | |
{% comment %} | |
Performs a redirect to the given URL, and tracks the visit inside Piwik | |
http://stackoverflow.com/a/36846720/3133038 (GitHub Pages redirect layout) | |
http://stackoverflow.com/a/8692588/3133038 (Redirect with Google Analytics tracking) | |
{% endcomment %} | |
<link rel="canonical" href="{{ page.redirect_url }}"/> | |
</head> | |
<body> | |
<h1>Redirecting to {{ page.title }}...</h1> | |
<a href="{{ page.redirect_url }}">Click here if you are not automatically redirected<a> | |
<script type="text/javascript"> | |
var _paq = _paq || []; | |
_paq.push(['setTrackerUrl', 'https://piwik.example.com/piwik.php']); | |
_paq.push(['setSiteId', 1]); | |
_paq.push(['trackPageView']); | |
</script> | |
<script src="https://piwik.example.com/piwik.js"></script> | |
<script type="text/javascript"> | |
window.location = "{{ page.redirect_url }}"; | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
permalink: /shorturl | |
layout: redirect | |
title: My nice external link | |
redirect_url: https://example.com/ | |
--- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment