Advanced Matching
Advanced matching allows TikTok to match events to users more accurately by sending hashed user identifiers.
Requirements
-
Enable Advanced Matching:
<script> window.handl_advanced_matching = 1; window.handl_tiktok_pixel_id = 'YOUR_PIXEL_ID'; </script> -
Collect User Data: The HandL library automatically collects user data from forms when advanced matching is enabled. It looks for:
- Email fields (email, email_address, e-mail, mail)
- Phone fields (phone, telephone, mobile, cell, phone-number, tel)
How It Works
-
Data Collection:
- When users fill out forms, HandL automatically captures email and phone number
- Data is stored in
localStoragewith keys:em(email) andph(phone)
-
Automatic Hashing:
- All identifiers are automatically hashed using SHA-256 before sending to TikTok
- Email is normalized (lowercase, trimmed)
- Phone numbers are cleaned (digits only)
-
External ID:
- Uses the
first_handlIDcookie asexternal_id - This is automatically generated on first visit
- Uses the
-
Automatic Identification:
- When TikTok Pixel loads and advanced matching is enabled,
ttq.identify()is called automatically - Identification is updated whenever new email/phone data is saved
- When TikTok Pixel loads and advanced matching is enabled,
Manual Data Collection
You can manually save user data for advanced matching:
HandL.saveAdvancedMatchingParams({
em: 'user@example.com', // Email (will be hashed)
ph: '+1-555-123-4567' // Phone (will be cleaned and hashed)
});
Note: The data will be automatically hashed when sent to TikTok.
Advanced Matching Parameters
TikTok supports the following identifiers (all SHA-256 hashed):
| Parameter | Description | Source |
|---|---|---|
email |
User's email address | localStorage.getItem('em') |
phone_number |
User's phone number | localStorage.getItem('ph') |
external_id |
Unique identifier | Cookies.get('first_handlID') |
Verification
To verify advanced matching is working:
- Open browser DevTools (F12)
- Go to Console tab
- Look for:
UTMSimple: TikTok advanced matching parameters sent - Check Network tab for requests containing hashed identifiers