# Tạo tham số UTM

URL: https://isharedigital.com/tao-tham-so-utm/
Ngày đăng: 2023-03-23
Cập nhật: 2024-05-06
Tác giả: iSharedigital

> Công cụ tạo link có tham số UTM để theo dõi nguồn khách trong Google Analytics. Điền thông tin chiến dịch, sao chép link và dùng ngay, không cần đăng ký.

---

## Tạo tham số UTM giúp xây dựng đường dẫn cho các chiến dịch marketing của bạn.

Nhờ vào các liên kết có thẻ UTM, bạn có thể xem dữ liệu về hiệu suất các chiến dịch quảng cáo Facebook và Google trong Google Analytics. Bạn cũng có thể phân tích lưu lượng truy cập đến từ các liên kết giới thiệu và backlink SEO.

![Tạo tham số utm](/wp-content/uploads/2023/03/Mobile-Marketing-bro-1024x1024.png)

<style>
  #utm-form {
    gap: 20px;
  }
  #utm-form,
  .form-group {
    display: flex;
    width: 100%;
    align-items: center;
  }

  .form-group label {
    min-width: 124px;
  }

  .form-group input,
  .column input {
    width: 100%;
    height: 38px;
  }
  .column {
    flex: 1;
  }

  .final-url {
    position: relative;
    background: #ddf6e4;
    padding: 20px 16px;
    border-radius: 4px;
  }
  .section-form-utm {
    padding: 24px;
  }

</style>
<h2>UTM Builder</h2>
<form id="utm-form">
  <div class="column">
    <div class="form-group">
      <label for="url">URL:</label>
      <input type="text" id="url" name="url" required><br><br>
    </div>

    <div class="form-group">
      <label for="utm_source">UTM Source:</label>
      <input type="text" id="utm_source" name="utm_source" required><br><br>
    </div>

    <div class="form-group">
      <label for="utm_medium">UTM Medium:</label>
      <input type="text" id="utm_medium" name="utm_medium" required><br><br>
    </div>

    <div class="form-group">
      <label for="utm_campaign">UTM Campaign:</label>
      <input type="text" id="utm_campaign" name="utm_campaign" required><br><br>
    </div>

    <div class="form-group">
      <label for="utm_content">UTM Content:</label>
      <input type="text" id="utm_content" name="utm_content"><br><br>
    </div>

    <div class="form-group">
      <label for="utm_term">UTM Term:</label>
      <input type="text" id="utm_term" name="utm_term"><br><br>
    </div>

  </div>

  <div class="column form-group final-url">
    <label for="final_url">Final URL:</label>
    <input type="text" id="final_url" name="final_url" readonly><br><br>
  </div>
</form>

<script>
  const form = document.getElementById("utm-form");

  form.addEventListener("submit", function (event) {
    event.preventDefault(); // Prevent the default form submission behavior

    buildUTM(); // Call the buildUTM() function

    // You can optionally add any other processing logic here
  });

  function buildUTM() {
    // Get the values of the form inputs
    const url = document.getElementById("url").value;
    const utm_source = document.getElementById("utm_source").value;
    const utm_campaign = document.getElementById("utm_campaign").value;
    const utm_medium = document.getElementById("utm_medium").value;
    const utm_content = document.getElementById("utm_content").value;
    const utm_term = document.getElementById("utm_term").value;

    // Add a trailing slash to the URL if it doesn't have one
    const formatted_url = url.endsWith("/") ? url : url + "/";

    // Build the UTM parameters
    const utm_params = [];

    if (utm_source !== "") {
      utm_params.push(`utm_source=${utm_source}`);
    }

    if (utm_campaign !== "") {
      utm_params.push(`utm_campaign=${utm_campaign}`);
    }

    if (utm_medium !== "") {
      utm_params.push(`utm_medium=${utm_medium}`);
    }

    if (utm_content !== "") {
      utm_params.push(`utm_content=${utm_content}`);
    }

    if (utm_term !== "") {
      utm_params.push(`utm_term=${utm_term}`);
    }

    // Add the UTM parameters to the URL
    const final_url = url + "?" + utm_params.join("&");

    // Set the final URL in the form input
    document.getElementById("final_url").value = final_url;
  }

  // Add event listeners to UTM input fields
  document.getElementById("url").addEventListener("change", buildUTM);;
  document.getElementById("utm_source").addEventListener("change", buildUTM);
  document.getElementById("utm_campaign").addEventListener("change", buildUTM);
  document.getElementById("utm_medium").addEventListener("change", buildUTM);
  document.getElementById("utm_content").addEventListener("change", buildUTM);
  document.getElementById("utm_term").addEventListener("change", buildUTM);

  const finalUrlInput = document.getElementById("final_url");
  finalUrlInput.addEventListener("click", function () {
    // Select the value of the input field
    this.select();

    // Copy the selected text to the clipboard
    document.execCommand("copy");

    // Show tooltip with message "Đã copy"
    const tooltip = document.createElement("div");
    tooltip.innerHTML = "Đã copy";
    tooltip.style.backgroundColor = "black";
    tooltip.style.color = "white";
    tooltip.style.position = "absolute";
    tooltip.style.top = "110%";
    tooltip.style.left = "50%";
    tooltip.style.transform = "translate(-50%, -50%)";
    tooltip.style.padding = "5px";
    tooltip.style.borderRadius = "5px";
    document.querySelector(".final-url").appendChild(tooltip);
    setTimeout(() => tooltip.remove(), 1000);
  })
</script>

## UTM tracking code là gì?

Các tham số UTM được đính kèm vào cuối của liên kết trỏ đến trang web của bạn, giúp bạn dễ dàng theo dõi hiệu suất của bất kỳ chiến dịch quảng cáo hoặc liên kết liên kết nào. Có năm tham số này, mỗi tham số bao gồm một phân đoạn dữ liệu khác nhau.

- **utm_source** - nguồn lưu lượng truy cập của bạn, ví dụ: google, email, facebook, bing
- **utm_medium** - phương tiện đã sử dụng cho nguồn của bạn. Ví dụ: cpc, email v.v.
- **utm_campaign** - tên của chiến dịch của bạn. Ví dụ: le_30-4, le_14-2
- **utm_content** - Được sử dụng cho thử nghiệm A/B và quảng cáo nhắm mục tiêu theo nội dung. Sử dụng utm_content để phân biệt quảng cáo hoặc liên kết trỏ đến cùng một URL.
- **utm_term** - Được sử dụng cho tìm kiếm có tính phí như [Google Ads](/google-ads-la-gi-cach-google-ads-hoat-dong/). Sử dụng utm_term để lưu ý các từ khóa cho quảng cáo này.

### Xem thông tin chi tiết hơn về UTM trong bài viết: [Tham số UTM](/tham-so-utm/)