Add Timestamp to all of your GA Events

Often there are situations where you are checking some user events and are wondering how to check which one was first, which was the next one, which was the last. Although there are several options to do that – they are all too clumsy to use them on regular basis (for example – using the GA User Explorer or even the worst option – using 3 extra dimensions in custom report for date/hour/minutes). That’s why it’s a great idea to add your own timestamp to all of your GA tags.

The following tracking is easy to implement with Google Tag Manager, requires a little JS coding and it’s extremely easy to use in daily basis. You will have easy-to-read timeline whenever you need it without any hassle. Even more – if you use it with the Client ID Tracking – you will have your own User Explorer!

Without further ado – here are the steps to implement Time Tracking to your GTM Tags:

Prepare GA for the Timestamp Tracking

First – create new Custom Dimension in your Google Analytics Account and name it however you like (don’t forget to remember the index when you create it). Make the dimension Hit Based, as you want to keep every hit separated with it’s own timestamp!
Create Timestamp Custom Dimension

Create the Timestamp JS Variable in GTM

Go to Variables, create new Custom Javascript Variable and add this code:

function() {
 try {
  var timestamp = new Date();
  var time = timestamp.toString().split(' ');
  return time[3]+ " " +time[1]+ " " +time[2]+ " "+time[4];
 } catch(e) {
  return "unknown";
 }
}

This little JS snippet will return the timestamp of the hit in format YYYY MM DD HH:MM:SS.
The reason to use this format is simple – it’s the easiest way to order the hits by ascending/descending order. If you want another format you can just swap the 5th row values (time[0] is the Day of the Week, time[1] is the month, time[2] is the day, time[3] is the year, time[4] is the time, time[5] is the timezone).

Connect your tags with the Timestamp Variable

The easiest, but the most important part of the tracking – linking everything together. In order to get the benefit of this tracking you need to add the newly created timestamp variable to all of your GA tags as custom dimension. Start with your GA Pageview tag:
Adding Timestamp to your Analytics tags Congratulations! Now you have your own histogram of all events, the easy way. If you want to check the order of pageviews/events – just add secondary dimension “Timestamp” (or however you named your custom dimension) and you are done.

Don’t forget to add this as custom dimension in ALL of your analytics tags (current and future ones)!


Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/turbose/public_html/wp-includes/wp-db.php on line 3030

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/turbose/public_html/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/turbose/public_html/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/turbose/public_html/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/turbose/public_html/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/turbose/public_html/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/turbose/public_html/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/turbose/public_html/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/turbose/public_html/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/turbose/public_html/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/turbose/public_html/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/turbose/public_html/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/turbose/public_html/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/turbose/public_html/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/turbose/public_html/wp-includes/class-wp-term.php on line 198

Check these related articles:


Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/turbose/public_html/wp-includes/wp-db.php on line 3030

Deprecated: Creation of dynamic property WP_Query::$comments_by_type is deprecated in /home/turbose/public_html/wp-includes/comment-template.php on line 1528

4 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.