An effective website is not just about good design and fast hosting. It also means:

  • understanding your audience — through web analytics tools;
  • automating technical processes — to avoid wasting time on routine tasks.

If your website is hosted on a VPS or dedicated server, you have maximum control: from connecting external services to setting up automated tasks. In this article, we’ll walk you through:

  • how to connect Google Analytics or Yandex.Metrica;
  • how to create and manage cron jobs on a VPS for backups, updates, and other tasks.

Why Is Analytics Important?

Without analytics, you work blindly. With it — you get answers to questions like:

  • How many people visit the site?
  • Where do they come from?
  • Which pages are popular and which are ignored?
  • Do advertising campaigns work?

This data helps you make informed decisions about design, content, advertising, and SEO.

Part 1: How to Connect Google Analytics to a Website

Step 1. Register in Google Analytics

  • Go to analytics.google.com.
  • Log in with your Google account.
  • Click “Create Property” — enter the name, time zone, and currency.
  • Choose platform type (web).
  • Enter your website URL (important: no mistakes).

Step 2. Get the Tracking Code

Google will generate a unique tracking ID (e.g., G-XXXXXXX).
You will receive a JavaScript code snippet that looks like this:

<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-XXXXXXX');
</script>

Step 3. Insert on Your Website

  • Log in via FTP, SSH, or the VPS control panel.
  • Open your site template (header.php, index.html, etc.).
  • Paste the code before the closing </head> or </body> tag.

If you are using VPS hosting, full file access allows you to make changes quickly and without restrictions.

Step 4. Check if It Works

  • Open the website in incognito mode.
  • In Google Analytics, go to “Reports” → “Real-time”.
  • If an active user appears — everything is working correctly.

How to Connect Yandex.Metrica

For many Ukrainian sites, Yandex.Metrica remains an alternative (or addition) to Google Analytics.

  • Go to metrika.yandex.ua.
  • Create a new counter — specify your site URL, time zone.
  • Select options: webvisor, click map, goals.
  • Copy the code:
<script type="text/javascript">
  (function(m,e,t,r,i,k,a){ m[i]=m[i]||function(){ (m[i].a=m[i].a||[]).push(arguments)}; m[i].l=1*new Date(); 
  k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a) })
  (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");

  ym(XXXXXXX, "init", { clickmap:true, trackLinks:true, accurateTrackBounce:true });
</script>
<noscript><div><img src="https://mc.yandex.ru/watch/XXXXXXX" style="position:absolute; left:-9999px;" alt="" /></div></noscript>

Insert it into the site template, just like with GA.

Part 2: What Is Cron and Why You Need It

Cron is…
…a task scheduler in Linux systems that allows scripts, commands, or actions to run on a schedule.

Used for:

  • backing up databases or files;
  • clearing cache or temporary data;
  • automatically updating content;
  • importing external data, parsing, API requests.

How to Create a Cron Job

Connect to your VPS via SSH:

ssh user@your-vps-ip

Open the scheduler:

crontab -e

Add an entry. Example:

0 2 * * * /usr/bin/php /home/user/site/backup.php >> /home/user/logs/backup.log 2>&1

This line runs a backup script every day at 2:00 AM.

Cron Syntax Explained

* * * * * command
│ │ │ │ │
│ │ │ │ └─ day of the week (0-6)
│ │ │ └──── month (1-12)
│ │ └────── day of the month (1-31)
│ └──────── hour (0-23)
└────────── minute (0-59)

Common examples:

Every hour:

0 * * * * /usr/bin/php /home/user/update-feed.php

Daily at 3:00 AM:

0 3 * * * /home/user/scripts/backup.sh

Every 15 minutes:

*/15 * * * * /usr/bin/php /home/user/parser.php

Why Cron Works Better on a VPS

On shared hosting, access to crontab may be limited or available only through a control panel. On a VPS:

  • full control over the system;
  • logging, restarting, testing possible;
  • flexible management of any task types.

On a dedicated server, there are no restrictions at all — you can launch complex command chains.

Tips

  • Always log the output:
>> /home/user/logs/task.log 2>&1
  • Use absolute paths to avoid errors caused by missing environment variables.
  • Test manually before adding to cron:
bash /home/user/scripts/test.sh

Conclusion

Connecting analytics and automating via cron are basic yet powerful tools:

  • they require no complex coding;
  • they allow you to control and improve the site without wasting time;
  • they open new possibilities for developing your online project.

Use a VPS or dedicated server — it’s the foundation for professional and efficient work. A reliable infrastructure is the key to a successful website.