It’s common for businesses to own multiple domains for various purposes. One of them is to have an easy-to-remember URL for use in a marketing campaign. Using call-eric.com is going to be more effective than using my full example URL: erics-example-urls.com, for a few reasons. The former is easier to remember and looks cleaner on the screen.
But what if I want to have call-eric redirect to my main website, and track how many visits I’m getting via the call-eric redirect?
One way to do it is to generate a URL that passes information to Google Analytics, and implement that as the redirect URL on your promotion website.
In order to do this, you’ll need three things:
- Google Analytics installed on your primary website,
- the Google URL Builder tool, and
- the ability to edit the .htaccess file for your promotion domain.
First, use the URL builder tool to generate a referral URL. This URL will pass various pieces of information over to Google Analytics. At a minimum, you will need to enter
- The URL of the website (that is, the site the redirect is pointing to);
- the campaign source– in this case, we’ll use “redirect”
- the campaign medium– here we’ll use “call-eric”, the name of the promotion site
- the campaign name, which simply names the campaign being used at the time. For this example, we’ll use “springspecials”.
Keep in mind that the fields can be named any way you want, these are merely suggestions. However you decide to organize the sources and mediums of your campaigns, be sure your names are descriptive, so you can determine what each piece of information means at a glance.
Once you have filled out the fields, click the “Generate URL” button at the bottom. This will create a URL that looks something like
“erics-example-urls.com/?utm_source=redirect&utm_medium=call-eric&utm_campaign=springspecials”
Any sessions on erics-example-urls.com will automatically pass the campaign source, medium, and name to the Google Analytics embedded on the homepage. This will show up in the “Campaign” section of the Google Analytics dashboard.
Now that we can get the information about people coming to the website via the promotion URL, we need to set up the redirect. There are two ways to do this: using your web hosting service’s control panel, or by modifying the .htaccess file.
If you are able to set a redirect to a custom URL via your web hosting service’s control panel, that’s the easiest way. Simply log into your account, find the hosted domain that you want to modify (the promotion domain), and set up a URL forward. The target URL is the one we got via the URL Generator.
The second way to do this is by editing the .htaccess file attached to the promotion site.
To do this, access the root folder of your promotion website via a file manager utility or FTP client. If you don’t see a file named “.htaccess”, ensure that hidden files are shown (this is a setting in your file manager or FTP client). If it’s still not there, you may not have one yet. Simply create a new file and call it “.htaccess”.
Once you have located the file, open it in your preferred code editor (something like Sublime Text, Notepad++, or if you have nothing else, a plain-text editor like Notepad; do not use a rich text editor like Wordpad, Word, OpenOffice Writer, etc).
With .htaccess open, add the following lines:
RewriteEngine On
RewriteRule ^$https://www.erics-example-urls.com/?utm_source=redirect&utm_medium=call-eric&utm_campaign=springspecials
Note that everything following “RewriteRule” is a single line.
Also, if you have multiple domains and only one .htaccess file, add this line after “RewriteEngine On”:
RewriteCond %{HTTP_HOST} call-eric\.com
This tells the server to check whether a visitor is trying to get to the promotion URL, and if so, to execute the redirect. Be sure to have a \ before any . (periods) in this line.
Save the .htaccess file, and after a moment, try to visit your promotion URL. If everything is done correctly, you should be redirected to the main site with a URL that contains all the campaign information you entered into the URL Generator. And once the data comes in, check Google Analytics, under “Campaigns” You should see a new hit that corresponds with the campaign information in the URL.