Hi Shopify Community,
I hope you are all doing well! I’m facing an issue with dynamically updating the heading on my product page based on a UTM parameter in the URL. I’ve implemented the following JavaScript code, but it’s causing the heading to be duplicated:
I’ve tried different versions of the code, but the issue persists. The heading appears duplicated. Can anyone provide insights into what might be causing this issue or suggest an alternative approach?
Any help or guidance would be highly appreciated. Thank you!
I tried that before but then it comes out like this:
including some padding which was already there i forgot to mention, need toget rid of that to.
Replace
titleElement.textContent = originalTitle + ’ - ’ + keyword;
with
titleElement.textContent = keyword;
1 Like
That removes the whole title and only shows the keyword in paragraph
ok found the issue.
You need to replace this line.
const titleElement = document.querySelector(‘.product__title’); // Adjust the selector accordingly
with
const titleElement = document.querySelector(‘.product__title h1’); // Adjust the selector accordingly
1 Like
No way man! How did u find that, I was testing for like 4 hours?? Thank you so so much, u got it 