We have not been able to adjust the source code on our page for a javascript rewrite.
The code that should be in the body tag, preferred to be right before the tag is:
The function is that the url has a query string of ?_vsrefdom=[Unique ID] and changes the phone number on a page. However, we can not seem to get it to show up in the source code.
Any help would be great.
1 Like
Hay matt,
Wix code is not intended to include script tags into a wix site. It allows you to write javascript code (that runs in a worker) and interacts with the site using the wix code APIs .
We do have APIs to read query string parameters, change texts on the page (such as change a phone number) and do a lot of other things. Let us know what you aim at doing so we can help better.
Our client has advertisement campaigns that run through google, bing, facebook, our owned and operated sites, and more. They want to track the calls they received from different campaigns. So, their sites phone number will change based on who’s advertisement they arrived from. This allows advertisers to direct resources towards products that are more likely to generate business.
I know that there are some apis you use for google analytics. But I have not seen one to update phone numbers based on the query string.
The code to update a phone number based on query string will look something like the following -
(assuming here the phone is displayed within a single text element with id TEXT1)
import wixLocation from 'wixLocation';
$w.onReady(() => {
let vsrefdom = wixLocation.query._vsrefdom;
if (vsrefdom === 'google')
$w('#TEXT1').text = '555-555-5555';
else if (vsrefdom === 'facebook')
$w('#TEXT1').text = '555-555-6666';
});