'm working on a custom page (page.contact-tech-support.json
) where I need to add a timestamp to the subject line of a mailto:
link (e.g., mailto:support@my-email.com?subject=CompanyPreformatted text Store Support Request - [timestamp]
).
Here’s the challenge:
- The
mailto:
link is inside atext
block in a JSON template. - Shopify’s strict sanitization on
type: text
blocks does not allowid
orclass
attributes on anchor tags, so I can’t directly target the link in JavaScript. - I’m using a script in
theme.liquid
to dynamically update the subject line with a timestamp usingquerySelector('.tech-support-link')
, but since I can’t add a class, I can’t target the link reliably.
I’ve tried these options:
- Using
id
orclass
on the link → blocked by Shopify sanitization. - Using
custom_liquid
→ not supported in this template context. - Targeting the link by
href
substring (e.g.,mailto:support@...
) as a fallback, but it’s not always reliable or ideal.
What I Need Help With:
- Best practice for injecting a timestamp into a mailto subject line when you can’t add identifiers to the
<a>
tag. - Whether there’s a cleaner way to output this link in a block that does allow
class
orid
(e.g., throughcustom-liquid
or another block type). - Where Shopify recommends placing this type of JavaScript logic in an OS 2.0 store setup (theme file, section, asset, etc.).
Any help or workarounds would be greatly appreciated!
Thanks in advance,
Seth