Demo repo for sample scripts that one can use for Analytics. The repo is meant to be used in conjunction with this deck - Analytics for WordPress. Instead of keeping limiting to just a talk and some slides, I thought it would be useful, if there are sample scripts documented and made ready for use.
For each of the files, the use case is documented in the comments. There is a configuration section, simply add your GA ID there, and the code will take care of the rest. If there are additional parameters which are use case specific, these would also be documented, just edit and use as per your pages.
Basic script initializationCustom EventCustom Event in a WordPress functions.php- User ID