New Blog Template and WP-Piwik

When creating a new site based on a template the new site has the same piwik id as the base template site. I came across this post, but I am receiving an error when I implement the posted code. https://premium.wpmudev.org/forums/topic/making-new-blog-template-work-with-wp-piwik#post-708494

Not sure if need to edit the code suggested, or if the posted code is now out-dated.