The first file is the script to be run, which you can store in your home directory. The second file is the systemd unit file which goes in /etc/systemd/system. Make sure on line 6 it references the location of the first file, and that you run systemctl daemon-reload after editing the unit file.
To run the service automatically on boot, run sudo systemctl enable avahi-alias@[domain]
, followed by sudo systemctl start avahi-alias@[domain]
to start it immediately.