Search code examples
google-analyticsutm

Date format for utm_from param


Is there a date encoding standard for utm_from parameters that work better than others ?

We'd like to just keep track of the day on which a given tracked link was released, it doesn't make sense to have minute/hour granularity, but I was thinking maybe Google Analytics worked better with a specific Date format ?


Solution

  • "utm_form" isn't an actual utm parameter; I'm assuming you're asking about utm params in general.

    All utm_* parameters are treated as strings by GA, so there is no format that will actually be treated as a date within GA reports.

    There are the standard rules that apply to all utm parameters:

    • Avoid special characters. No &s or #s (if you use them, make sure they're url-encoded). In general, it's best to stick with letters, numbers, dashes and underscores, to avoid potential encoding issues.
    • Lead with most important info and avoid unnecessary verbosity. This is a niche thing, and should probably be your last consideration, but in cases where the URL gets chopped off (say, in a plain-text email), data has better chance of getting tracked the farther left (in terms of character count) it is.

    The rest of the considerations are based on your preferences and needs (and those of anyone who may access in the future):

    • Readability. You probably don't want to use 20160908 because it's not too human-friendly. And as you said, some standards are day first and others are month first, so putting the full year first is a good way to mitigate that ambiguity.
    • Use standard date formats for custom integrations. Even if you have none currently, you should consider standards as they can make custom integrations/reporting easier in the future. The ISO format (e.g. 2016-09-08) is widely compatible and easily parseable. If using JS, be wary that the Date's method toISOString() returns the time in UTC; getting local time or some other timezone requires custom tweaking.
    • Ordering. Think about the natural sort order of your format. The ISO format (2016-09-08) for instance, will sort chronologically.
    • Extra info. Think about day-related data that's easy for you to include in the format; data you do not need now, but may be good to have if you ever do need it. For instance, maybe you should include day of week (Mon, Tue, etc)? Gives you another way to slice your data without external tools. On the other hand, simpler is better, so don't go crazy with this :)
    • Timezone. If you're populating utm params from multiple timezones, you'll want to either include the timezone in the utm value, or standardize all values to a single timezone.

    Some of these considerations conflict with each other (e.g. include extra info vs standard format?); you'll need to weigh them according to your needs.