module UtmParameterAudit

Overview

Audit the UTM parameters of a list of links. Pure string work: no network and no URI library. It reads the text of the links you give; it does not open them and does not know which names your analytics tool expects.

Defined in:

utm_parameter_audit.cr

Constant Summary

BAD_CHARS = "space, + or %20 in utm value"
CASE_PARAMS = ["utm_source", "utm_medium", "utm_campaign"] of ::String
CHECKS = [MISSING_SOURCE, MISSING_MEDIUM, MISSING_CAMPAIGN, EMPTY_VALUE, UPPER_CASE, BAD_CHARS, DUPLICATE, NO_QUERY]
DUPLICATE = "same utm parameter twice"
EMPTY_VALUE = "empty utm value"
MISSING_CAMPAIGN = "missing utm_campaign"
MISSING_MEDIUM = "missing utm_medium"
MISSING_SOURCE = "missing utm_source"
NO_QUERY = "no query string"
REQUIRED = ["link_id", "url"] of ::String
UPPER_CASE = "upper-case letter in utm value"
USAGE = "usage: utm-parameter-audit links.csv\nCSV columns: link_id, url. It reads the text of the links you give; it does not open them and does not know which names your analytics tool expects. More: https://www.onegtmlab.dev/blog/the-automated-linkedin-content-distribution-system-for-b2b-business"
VERSION = "1.0.0"

Class Method Summary

Class Method Detail

def self.audit(links : Array(Link)) : Report #

[View source]
def self.check(url : String) : Array(String) #

The problems of one link, each check at most once. A link with no query string reports only that: the missing-parameter checks apply to links that have a query string.


[View source]
def self.cli(args : Array(String), stdout : IO, stderr : IO) : Int32 #

Exit codes: 0 no problem, 1 any problem, 2 unreadable or bad input.


[View source]
def self.parse_csv(text : String) : Array(Array(String)) #

Small CSV reader: comma separated, double quoted fields may hold commas, line breaks and "" for a quote mark. Returns rows of raw cell strings.


[View source]
def self.parse_query(query : String) : Array(Tuple(String, String)) #

Splits a query on "&", each pair on the first "=". Names are lower-cased, values are kept as written. Empty segments are skipped; a pair with no "=" has an empty value.


[View source]
def self.query_of(url : String) : String | Nil #

Text before the first "#", then the part after the first "?" (nil when there is no "?").


[View source]
def self.read_links(text : String) : Array(Link) #

[View source]
def self.render(r : Report) : String #

[View source]
def self.table(rows : Array(Array(String))) : String #

[View source]