We’ve implemented a EE installation as a URL shortener. For the most part it is working. This is a corporate shortener. That means there is only a few people that can create the short url’s and we also use it as an automated service for every page.
The question that I have is regarding SEO practices and Google Analytics best practices. It seems that we are not really getting any tracking of our short URLs. since we use those as a campaign or marketing efforts, this is very important to us. Any insights or help will be appreciated. Attached below is the code we are using.
NOTE: we thought that maybe immediately embedding the GA code in an embedded template would help us, but it does not look like it. {embed="shorturl/analyticstracking"}
{embed="shorturl/analyticstracking"}
{if segment_1==''}
<?php
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: <a href="http://www.mywebsite.com">http://www.mywebsite.com"</a> );
exit();
?>
{/if}
{if segment_1!=''}
{if segment_2==''}
{exp:channel:entries channel="shorturl" limit="1" url_title="{segment_1}"}
{if no_results}
{redirect="shorturl/404"}
{/if}
<?php
$destinationURL = '{url_destination}';
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: {url_destination}?utm_source=redirect_shorturlsite&utm_medium=link&utm_content=alias&utm;_campaign={url_title}" );
exit();
?>
{/exp:channel:entries}
{if:elseif segment_2!='' OR segment_3!='' OR segment_4!='' OR segment_5!='' OR segment_6!=''}
{redirect="shorturl/404"}
{/if}
{/if}