How to Perform Cost Analysis through Google Analytics

Whether you're running a business website or a professional niche blog, there's always some active marketing channels that involves both expenditure and revenue generation. Generally, we track the traffic flow going through these channels through different ways. If you're running some AdWords campaigns, you can easily track their performance both within AdWords dashboard as well as in Google analytics. But what about other marketing campaigns running on your website or blog? How to perform detailed cost analysis associated with each marketing channel maintained by a 3rd party service? Fortunately, Google provides you with a powerful cost analysis report that can be used in such conditions. Let's see how we can use this feature to find out how profitable are our various marketing efforts running on our websites.

Benefits of GA Cost Analysis Report

Before you prepare for using cost analysis report, you must know what exactly this report contains and how it helps you optimize your affiliate, product or ad marketing campaigns. Cost analysis reporting works on a simple principle. It compares the cost incurred in your campaigns against the revenue generated by you. This way you can find out all the important metrics discussed below.

Cost analysis report metrics in Google analytics

The five most important metrics that gives you a clear picture about the success of your marketing campaign are Cost, CPC, RPC, ROI and Margin. Let's see each of these metrics and understand how beneficial this report is in tracking the success of our marketing channels.
  • Cost - This important metric gives the overall cost of a marketing campaign running on your website. It may also include goal value cost that may directly or indirectly indicate the cost incurred in running a marketing channel.
  • Cost per click (CPC) - If you're running a direct ad campaign on a CPC basis, this metric helps you evaluate how multiple ads on the same slot are giving different click rates under different conditions (e.g. home page, day of week).
  • Revenue per click (RPC) - This is the overall monetary gains per click including your expenditure, advertiser's cost and your profit. In simple words, this metric shows the combined revenue generated for a single click.
  • Return on investment (ROI) - If you're already using goals in Google analytics, you can easily understand about ROI. This metric shows what you're getting against your own expenditure for a specific marketing campaign.
  • Margin - And last but not the least is the net profit in percentage coming in your hands after deducting every other value. This metric tells the profitability factor for each and every campaign at a glance.
The other metrics included in this report can be easily tracked via regular analytics reports available in different sections. Now let's see the entire procedure of capturing all this important data that eventually creates the cost analysis report.

The entire procedure of using this report can be divided into five different parts. The first part involves extensive tagging activity of all the campaign URLs so that the essential data can be tracked and accumulated that is later fed to the cost analysis system. The next phase involves creating a custom CSV file that contains all the important data you've collected related to your marketing campaign. The third phase involves creation of a data source that acts as an entry point for the data that will be uploaded through your CSV file containing all the cost data associated with a campaign. Fourth phase obviously involves cost data upload procedure so that Google analytics can churn it to create a cost analysis report. The fifth and the last phase involve report analysis which can be easily done right within your Google analytics dashboard.

So let's go through each of these phases and see how to leverage this powerful feature available in Google analytics.

Tag All Custom Campaign URLs

You may be running a direct ad, selling an eBook, offering a newsletter subscription service and other similar kinds of custom marketing campaigns on your website. Some of these campaigns may involve multiple web pages for a single process to complete. The first step is to tag all the important links present in your marketing channel. These links can be web page links, download links, submission links, and purchase button links and so on.

If you've familiar with Google Analytics URL Builder, you can easily start the tagging activity right away. If you do not know how to use this URL builder, you can follow this easy-to-understand guide for creating tags for your custom campaigns. While tagging all the links, make sure you create easy-to-remember and meaningful tags so that you can easily identify them in the analytics reports.

Collect Cost Data in A CSV File

This is one of the important phases where you've to collect the relevant cost data from different sources. Some of the campaign activity data can be exported in CSV format directly from Google analytics dashboard. The other cost related data that may be stored in an external source should be exported as well.

CSV export option in Google analytics

If all the links are correctly tagged, you can easily collect the associated data from the 'Standard Reporting' section through Traffic Sources → All Traffic as shown in the image above. Other cost data that may be stored on a 3rd party server (e.g. ad inventory management service, form submission service) should be exported from the respective account as well.

Once all the cost data has been retrieved, you have to merge them and have to format them in a proper way that can be fed to your Google analytics account. A typical CSV file contains records on new line delimited by commas. While preparing a cost data CSV file, you must take care of the following constraints.
  • You must use UTF-8 character encoding for your CSV file.
  • The file size should not exceed 5 MB.
  • The first line is treated as a header and should not be empty.
  • All mandatory column headers cannot be skipped.
  • At least one metric should be included in the header along with the mandatory dimensions.
  • Large data set containing multiple files must have matching headers.
  • The two mandatory column headers are ga:source and ga:medium.
  • Values for both these mandatory column headers cannot be empty in any row.
  • Empty cells for non-mandatory fields will default to zero.
Now let's look at the sample entry for a cost data CSV file so that you can get a fair idea about the structure of this file.

ga:source,ga:medium,ga:keyword,ga:adCost,ga:adClicks,ga:impressions
BSA ads,cpc,ebook,10.85,49,16958
BSA ads,cpc,web server,20.69,55,24112
BSA ads,cpc,VOIP,4.04,28,13547

You can see the header line in bold letters consisting of column headers that are formatted in a way that Google analytics understand and can process. Here's a complete reference for formatting your cost data CSV file.

If you get an error while importing your CSV file, you must cross check for its validity. In your first few attempts you may get such errors as correctly formatting the CSV file with the required values takes some time.

Create a Custom Data Source for Importing CSV Data

Once the data collection is done through tagging and the process of cost data CSV file creation is also complete, we can move on to the next phase. Now comes the essential phase of creating an entry point for the CSV file. In simple words, a custom data source will act as a container for the imported data. Creating this custom data source is extremely simple.

Custom data source for cost data import in Google analytics

Go to Admin → Custom Definitions → New Custom Data Source, to start the source creation process. Simply provide the name, description, type and profile for the custom data source. Type of data source is generally 'Cost' and the relevant website profile should be selected with care with which you want to associate the data source. As soon as the data source is created, you'll get a unique UID as shown in the image above. This UID is used while importing the CSV file which is explained in the next section.

Upload Cost Data Using Google Management API

The last major step is to import the cost data CSV file into your Google analytics account. There's no direct interface for uploading this file within the analytics dashboard. You have to use Google Management API which is available in Java and Python and is easy-to-use. Before you use the management API, you must register an application through Google APIs console and must create an Analytics service object. And here's a simple Java code to upload your cost data CSV file through Google Management API.

try {
File file = new File("bsa_summer_sale.csv");
InputStreamContent mediaContent = new InputStreamContent('application/octet-stream', new FileInputStream(file));
mediaContent.setLength(file.length());
Upload upload = analytics.management().dailyUploads().upload("4321",
"UA-4321-1", "xW1mS3l5R7srwLf9Z0LT-A", "2012-11-28", 1, "cost", mediaContent);

upload.setReset(true);
DailyUploadAppend append = upload.execute();

} catch (GoogleJsonResponseException e) {
System.err.println("Service error!"
+ e.getDetails().getCode() + " : "
+ e.getDetails().getMessage());
}

I'm assuming you've already created and instantiated the Analytics service object for accessing the management API. Now let's take a close look at the file uploading code shown above. The file name "bsa_summer_sale.csv" is given as an argument which holds all the cost data. Obviously you may name your file as per your choice. You can see several other parameters in bold letters. The parameter '4321' is the Google analytics account ID. The next parameter 'UA-4321-1' is the web property ID associated with a specific website on which your custom campaign is running.

Next important parameter 'xW1mS3l5R7srwLf9Z0LT-A' is the UID which you will get while creating a custom data source already discussed in the previous section. Right after this parameter, you can supply the upload date on which you're importing your cost data CSV file. The next vital parameter tells the management API whether it's the first file upload or the nth file upload for a large data set. Remember, this parameter accepts integer value so do not use double quotes while providing the value for this argument. And the last parameter tells the type of data being uploaded which is almost always of type 'Cost'.

Once the data is uploaded, it may take few days before you can see the reports in your analytics dashboard. If you get errors while uploading the file, check for any formatting problem within the file that may be restricting the successful upload.

Access and Use Cost Analysis Report

This last phase is a cakewalk for all of us. You simply have to access the relevant report to analyze the success or failure of your marketing channels running on your website. To access this report go to Standard Reporting → Traffic Sources → Cost Analysis.

If the data set is huge, you can also export this report for offline analysis. Business and eCommerce websites running key marketing campaigns that are maintained by 3rd party services will find this powerful feature extremely useful in assessing the effectiveness of each and every marketing channel.

Cost analysis report graph

Since the entire upload history is maintained in the analytics account, you can easily delete the selective uploads to change the reports accordingly. To manage the deletion of uploads, you must access the associated custom data source. You can mash up selective fields from this report to create a custom report that can provide flexible and easy-to-understand visualizations for correctly assessing the performance of every marketing channel.

If you enjoyed this article, get email updates (it's free).


blog comments powered by Disqus

NEXT POST: Newer Post PREVIOUS POST: Older Post Home
 

About Rajeev Edmonds

FreshTechTips author - Rajeev EdmondsRajeev Edmonds is a technical editor who loves to explore and test new gadgets and apps. He loves to develop applications both for desktops and web. He also enjoys writing tutorials for new media tools and services. The other two niche blogs that he maintains are MintBlogger and Taste Defined.

He has been developing custom skins for WordPress blogs since 2010. He also shares practical tips to get more out of your electronic gadgets. Read more →

Get Custom Design For Your Blog

Website showcase A unique blog design has the power to get more leads and prospects for your business.

Custom designs are know to perform better than a standard commonly used theme. Search traffic loves unique and optimized blog design. Move ahead and change your blog’s theme today!

Request a Free Quote!

Start Your WordPress Blog

WordPress logo Are you looking to build a self-hosted WordPress blog? Do not wait and get one for you today!

A self-hosted WordPress blog not only gives to total control over every aspect of blogging, but it also provides killer ways to boost your online business. Start your WordPress blog today!

Get Free WordPress Setup!