Tập lệnh Thông minh OneLink V2
Khát quát: Tùy chỉnh OneLink được tự động tạo và nhúng sau một nút hoặc biểu ngữ trên trang web thương hiệu của bạn.
Giới thiệu về Tập lệnh Thông minh OneLink
Tập lệnh Thông minh OneLink sử dụng các URL gửi đến đưa đến trang web để tự động tạo các URL OneLink gửi đi duy nhất đưa đến cửa hàng ứng dụng.
Các URL gửi đi được tạo bằng cách sử dụng các đối số bạn nhận được từ nhà tiếp thị và nhập vào tập lệnh. Lưu ý: Đối số afParameters
có cấu trúc được tạo từ nhiều đối số (thông số) khác, mỗi đối số chứa một đối tượng cấu hình có mã khóa, giá trị ghi đè và giá trị mặc định.
Các bước thực hiện
Để thiết lập Tập lệnh Thông minh, bạn có thể:
Embed the script in your website
The Smart Script initialization and calling code can be either come from the Smart Script generator in the AppsFlyer dashboard (recommended), or imported and called manually by the developer.
Preserve incoming URL parameters
In order to ensure incoming URL parameters will be mapped to the generated OneLink, it is recommended to import the Smart Script in every website page, whether a OneLink is generated in the page or not.
Available from version 2.5.0.
More details and a full example here.
Sử dụng mã do trình tạo Tập lệnh Thông minh tạo ra
- Nhận tệp tin từ nhà tiếp thị bao gồm tập lệnh, mã khởi tạo và đối số.
- Test the script on the Smart Script test page. Ensure the correct outgoing URL is generated.
- Làm theo hướng dẫn thử nghiệm và sử dụng kết quả Tập lệnh Thông minh.
Xem ví dụ tích hợp trên Github
Cấu hình tập lệnh theo cách thủ công
- Tải xuống tập lệnh.
- Nhận các đối số để gọi tập lệnh ánh xạ các thông số gửi đến với các thông số gửi đi từ nhà tiếp thị.
- Khởi tạo đối số Tập lệnh Thông minh và đối tượng cấu hình.
- tạo URL bằng cách gọi tập lệnh trong HTML web/trang đích bằng phương thức sau:
var result = window.AF_SMART_SCRIPT.generateOneLinkURL({
oneLinkURL,
afParameters,
referrerSkipList, // optional
urlSkipList // optional
})
Kiểm tra và sử dụng kết quả Tập lệnh Thông minh
- Kiểm tra giá trị trả về trong
result
. Giá trị trả về có thể là:- An outgoing Onelink URL. Use the result value as needed. For example, to place it as a link under a CTA on your website.
null
. Nếu tập lệnh trả vềnull
, hãy triển khai luồng quy trình mong muốn. Ví dụ: URL hiện tại của web/trang đích không được thay đổi.
var result_url = "No output from script"
if (result) {
result_url = result.clickURL;
// Put the generated OneLink URL behind CTA buttons
document.getElementById('andrd_link').setAttribute('href', result_url);
document.getElementById('ios_link').setAttribute('href', result_url);
// Optionally - Create QR code from the generated OneLink URL
window.AF_SMART_SCRIPT.displayQrCode("my_qr_code_div_id");
//The size of the QR code is defined in the CSS file under #my_qr_code_div_id
// #my_qr_code_div_id canvas {
// height: 200px;
// width: 200px;
//}
// Optionally - fire an impression.
// The impression will fire to https://impressions.onelink.me//....
setTimeout(() => {
window.AF_SMART_SCRIPT.fireImpressionsLink();
console.log("Impression fired");
}, 1000);
}
Use Google Tag Manager
Để thiết lập Tập lệnh Thông minh trong Trình quản lý Thẻ của Google:
- Confirm that the marketer followed their instructions and placed the Smart Script code into GTM.
- Kiểm tra giá trị trả về trong
AF_SMART_SCRIPT_RESULT
. Giá trị trả về có thể là:- URL Onelink gửi đi. Sử dụng giá trị kết quả nếu cần. Ví dụ, để đặt giá trị này dưới dạng liên kết trong CTA trên trang web của bạn.
null
. Nếu tập lệnh trả vềnull
, hãy triển khai luồng quy trình mong muốn. Ví dụ: URL hiện tại của web/trang đích không được thay đổi.
var result_url = AF_SMART_SCRIPT_RESULT.clickURL;
if (result_url) {
document.getElementById('andrd_link').setAttribute('href', result_url);
document.getElementById('ios_link').setAttribute('href', result_url);
// Optionally - Create QR code from the generated OneLink URL
window.AF_SMART_SCRIPT.displayQrCode("my_qr_code_div_id");
//The size of the QR code is defined in the CSS file under #my_qr_code_div_id
// #my_qr_code_div_id canvas {
// height: 200px;
// width: 200px;
//}
// Optionally - fire an impression.
// The impression will fire to https://impressions.onelink.me//....
setTimeout(() => {
window.AF_SMART_SCRIPT.fireImpressionsLink();
console.log("Impression fired");
}, 1000);
}
- Test the script on the Smart Script test page. Ensure the correct outgoing URL is generated.
Create a QR code with the Smart Script result
Prerequisite: Smart Script V2.6+
Best practices
- Customize the QR code according to your app brand with a center logo and a relevant code color
- Show the QR code when users are on desktop and show the button with the link when users are on mobile
Để tạo mã QR:
- Tạo thẻ div với ID cụ thể trong trang HTML của trang web để lưu trữ mã QR.
Bạn có thể tạo kiểu cho thẻ div theo cách mong muốn. - After you run the Smart Script and generate a OneLink URL, call the following method
displayQrCode
displayQrCode
displayQrCode
Chữ ký phương thức
const qrOptions = {
logo,
colorCode
}
window.AF_SMART_SCRIPT.displayQrCode(divId, qrOptions)
Đối số đầu vào
Loại | Bắt buộc | Tên | Mô tả | Comment |
---|---|---|---|---|
String | Có | divID | A div tag with a specific ID in your site's HTML page to host the QR code | |
Object | Không | qrOptions | Configuration object (see details in the table below) | If the object is missing, the QR code will be created without a logo in default color |
qrOptions
object
Loại | Bắt buộc | Tên | Mô tả | Comment |
---|---|---|---|---|
String | Không | logo | A valid image URL or an image data-URI | If the value is invalid, the QR code will be generated without the logo |
String | Không | colorCode | Hex color of the QR code | If the value is invalid, the code color will fallback to the default black color |
Usage examples:
- QR code without logo and without custom color Github example
- QR code with logo and custom code color Github example
Fire an impression
You can fire an impression when a page loads, a CTA or banner displays, etc. Note: Impressions can only be fired on mobile devices; not on desktop.
Điều kiện tiên quyết: Tập lệnh Thông minh V2.2+
Để kích hoạt lượt hiển thị:
- Làm theo hướng dẫn để chạy Tập lệnh Thông minh và tạo URL lượt nhấp.
- Đảm bảo rằng kết quả là hợp lệ (và không phải null).
- Chạy chức năng hiển thị sau:
A must-do workaround
Please wrap the call to
fireImpressionsLink
vớisetTimeout
to make sure there is at least 1 second of delay between the call togenerateOneLinkURL
andfireImpressionsLink
setTimeout(() => {
window.AF_SMART_SCRIPT.fireImpressionsLink();
console.log("Impression fired");
}, 1000);
You can find examples for firing impressions for mobile only and for cross platform support
Đối số
Đối số | Nhận xét | Ví dụ: | |
---|---|---|---|
oneLinkURL (bắt buộc) |
|
|
|
afParameters (bắt buộc)
|
mediaSource (bắt buộc) |
Đối tượng cấu hình cho nguồn truyền thông |
|
campaign |
Đối tượng cấu hình cho chiến dịch |
|
|
channel |
Đối tượng cấu hình cho kênh |
|
|
ad |
Đối tượng cấu hình cho quảng cáo |
|
|
adSet |
Đối tượng cấu hình cho bộ quảng cáo |
|
|
deepLinkValue |
Đối tượng cấu hình cho |
|
|
afSub1-5 |
Đối tượng cấu hình cho |
||
googleClickIdKey |
Nêu rõ cần gọi thông số chứa GCLID là gì. |
||
Các thông số truy vấn (tùy chỉnh) khác |
|
|
|
referrerSkipList |
List of the strings in the HTTP referrer for a particular click (for example Twitter or Meta ads) that if found, cause the Smart Script to return null . This can be useful for SRNs like Twitter and Meta ads, for which clicks are already reported.
|
||
urlSkipList |
Danh sách các chuỗi trong URL cho một lượt nhấp cụ thể (ví dụ: af_r ) mà nếu được tìm thấy, sẽ khiến tập lệnh Thông minh trả về null . Điều này có thể hữu ích nếu bạn sử dụng đường dẫn phân bổ của AppsFlyer với af_r để chuyển hướng người dùng đến trang web trên điện thoại di động của bạn và không muốn bị mất dữ liệu từ lượt nhấp ban đầu.
|
||
webReferrer |
This argument defines a key in the outgoing URL, which its value will be a copy of the HTTP document.referrer . The referrer is saved in the first page the user lands in, and may be used in any consecutive page in this domain which runs Smart Script with this argument.
|
Đối tượng cấu hình
Tập lệnh Thông minh OneLink sử dụng các đối số để tạo URL gửi đi dựa trên các thông số của URL gửi đến và các đối số được xác định trong tập lệnh. Đối số afParameters có cấu trúc được tạo thành từ nhiều đối số (thông số) khác được sử dụng để phân bổ và liên kết sâu, mỗi đối số chứa một đối tượng cấu hình có mã khóa, giá trị ghi đè và giá trị mặc định, như được mô tả trong bảng sau.
Đối số | Mô tả | Ví dụ: |
---|---|---|
keys |
|
|
overrideValues |
|
Ví dụ: {'video': 'video_new'} Đối với thông số kênh trong tập lệnh, bất cứ lúc nào giá trị gửi đến là video, thì tập lệnh sẽ thay đổi giá trị đó thành video_new trên liên kết gửi đi. |
defaultValue |
|
Ví dụ: ['web_video'] Đối với thông số kênh trong tập lệnh, nếu bạn không tìm thấy thông số in_channel, thì web_video sẽ được sử dụng làm giá trị kênh. |
Ví dụ:
Basic attribution
Xem ví dụ về việc chuyển đổi cơ bản một URL gửi đến thành một URL OneLink gửi đi, với một mã khóa duy nhất cho media_source và campaign
Multiple keys
Xem ví dụ về chuyển đổi một URL gửi đến thành một URL OneLink gửi đi, với nhiều mã khóa cho media_source và campaign.
UTM parameters
Xem ví dụ về việc chuyển đổi một URL gửi đến thành một URL OneLink gửi đi, với các thông số UTM cho media_source và campaign.
Override values
Xem ví dụ về việc chuyển đổi một URL gửi đến thành một URL OneLink gửi đi, thay thế giá trị media_source gửi đến.
Default values
Xem ví dụ về việc chuyển đổi một URL gửi đến thành một URL OneLink gửi đi, sử dụng giá trị mặc định khi không tìm thấy giá trị media_source gửi đến.
Forced default values
Xem ví dụ về việc chuyển đổi một URL gửi đến thành một URL OneLink gửi đi, sử dụng giá trị mặc định ngay cả khi tìm thấy giá trị media_source gửi đến.
Google click ID passthrough to af_sub
Xem ví dụ về việc chuyển đổi một URL gửi đến thành một URL OneLink gửi đi, chuyển ID lượt nhấp của Google đến af_sub4. Lưu ý: Khi tìm thấy GCLID, tập lệnh sẽ tìm từ khóa thông số gửi đến và đặt giá trị từ khóa trong URL gửi đi làm giá trị af_keywords.
Facebook click ID passthrough to af_sub
Xem ví dụ về việc chuyển đổi một URL gửi đến thành một URL OneLink gửi đi, chuyển ID lượt nhấp của Facebook đến af_sub2.
Set attribution and OneLink parameters
Xem ví dụ về việc chuyển đổi một URL gửi đến thành một URL OneLink gửi đi với phân bổ AppsFlyer và các thông số OneLink.
Set additional custom parameters
Xem ví dụ về việc chuyển đổi một URL gửi đến thành một URL OneLink gửi đi với các thông số tùy chỉnh bổ sung (bao gồm cả thông số af_prt đối với đại lý).
Referrer skip list
See example of how you can disable the Smart Script for a particular click (for example, from Twitter or Meta ads) by creating a skip list. If any of the strings in the skip list appear in the HTTP referrer of the click, the Smart Script returns null
.
URL skip list
Xem ví dụ về cách bạn có thể tắt Tập lệnh Thông minh cho một chuỗi cụ thể trong URL (ví dụ: af_r
) bằng cách tạo danh sách bỏ qua. Nếu có bất kỳ chuỗi nào trong danh sách bỏ qua xuất hiện trong URL của lượt nhấp, thì Tập lệnh Thông minh sẽ trả về null
.
Smart Script set up with Google Tag Manager
Xem ví dụ về việc chuyển đổi một URL gửi đến thành một URL OneLink gửi đi bằng Tập lệnh Thông minh OneLink được thiết lập bằng Trình quản lý Thẻ của Google.
Impressions - OneLink Template with mobile-only support
See example of an impressions fired using a OneLink template who has only mobile device.
A must-do workaround
Please wrap the call to
fireImpressionsLink
vớisetTimeout
to make sure there is at least 1 second of delay between the call togenerateOneLinkURL
andfireImpressionsLink
Impressions - OneLink Template with Cross-platform support
See example of an impressions fired using a OneLink template who has cross-platform support.
For example an impression fired from a non-mobile platform (e.g desktop or console).
Firing an impression from a cross platform landing page
You can find here a code example for firing an impression from a demo landing page
A must-do workaround
Please wrap the call to
fireImpressionsLink
vớisetTimeout
to make sure there is at least 1 second of delay between the call togenerateOneLinkURL
andfireImpressionsLink
Preserve incoming URL parameters across pages
Available from version 2.5.0.
Incoming parameters (e.g. utm_source
) from a landing page are not passed to other pages in the website by default.
Importing Smart Script in every website page preserves the incoming URL parameters, and allows Smart Script to use them in other pages.
You can find here an example of this use case.
Copy HTTP referrer to outgoing URL
Available from version 2.7.0.
This example demonstrates how to copy the HTTP document.referrer
to a key defined by webReferrer
in the outgoing URL. The referrer is saved in the first page of the website the user lands in, and may be used in any consecutive page in this domain which runs Smart Script with this argument.
Đã cập nhật 2 tháng trước