Anyone getting referral codes into their bot?

Hey bot makers!

Has anyone successfully implemented the use of referral codes.

For now, I use Viral Loops. If an invitee clicks a link, my site opens with a unique referral code in the URL. However, I can’t fetch that code from the bot output. Thereby the referrer will not get the award that he or she rightfully should.

Have anyone solved this or is there someone who is using another referral system than Viral Loops, which integrates better with Tars?

All ideas and input will be highly appreciated.



Hi @Thomas,

The referral code that you added, is it added as a URL parameter in the URL?
Can you share the webpage where you have added the widget with the referral code in the URL, I’ll take a look.

Hi @vinit

Sure, the URL looks like this:

HJv5M0BrG is the ID of the referrer and I need to get that info into the bot, so I can attribute the referrer his/her points for a successful referral.


1 Like

Got it, You want the URL param of the parent page on which the bot widget is there.
Currently this data is not available from within the Bot, but it would be easy to include it.

Let me see, what’s the best way to include this data

Many thanks @vinit, would be awesome. Also for campaign tracking with UTM URLs and so on :wink:

1 Like

Got it.
BTW, I just made a video about using the URL param for tracking where the submissions is coming from. Nothing new here, but still thought i’ll just put it here for others to check:

Great @vinit - and many thanks for looking into it!

However, I have this URL, which I think follows the structure you explain in the video:

But… in the bot ‘partial data’ output I don’t get the referral code:

1 Like

@vinit, I tried again, same outcome - could it be that this solution does not work with the ‘speaking bot’ option? I mean, even though this is the displayed URL ( ), maybe there is the underlying ‘speak URL’ which cause the problem, as I see this in my ‘partial data’ section:
Please, let me know what solution you suggest in this case :slight_smile:

1 Like

Hey Thomas,

The URL param that you are adding is in the URL of the parent page where the bot widget is added, and not in the URL of the Chatbot itself. That’s why they are not coming in the submissions.

For that you need to add those params in the code snippet, but that would mean that you need to make that change in the page html containing the code snippet in a dynamic way.

Why don’t you ping us on the live chat on the TARS Dashboard, and we will find some solution.

Is it possible to reference the URL parameters in an API call? For example if we were using the GET to pull data from a Google Spreadsheet, is it possible to make that call if the I added ?ref=49383 to the bot URL and then added SELECT A, B, C WHERE A={{urlp.ref}}?

I tried it once and it seemed to work (I thought), but I couldn’t replicate it. I was experimenting with three different bots doing variations of the call, so I could have mixed it up.

1 Like

Try this instead:

SELECT A, B, C WHERE A=’{{urlp.ref}}’

when the value to compare is a number, this might be needed. I am not sure, will have to check.

Still getting this error message when debugging “Error in template eval code: var r=[];r.push(this.pre.fetch.table.rows[0]);return r.join(”");"

This is the link I’m experimenting with:
It seems like it’s having trouble pulling the number from the URL parameter.

I have used this code repeatedly in other experiments with success just to weed out any foolish errors on my part haha.

This one in particular is SELECT A, B, C, D, E, F WHERE D={{urlp.ref}}

1 Like

I worked through it and figured out the problem. It was an issue with my columns in the Google Sheet itself and not the url parameters. I just spent two hours chasing my tail for the simplest mistake ever :confounded:

1 Like

Great. You figured it out.
That happens sometimes, when debudding issues like these. :smile:

1 Like

Can you please do a walkthrough video tutorial of all the steps

1 Like

Hey @Starkiss,

This is the video tutorial for the same. Are you looking for something else?

I understand the example for adding tracking code to the bot URL itself but do we have a way to add tracking code for embedded bots?

Example: I send clients through a Google ad to a landing page called

They interact with a bot embedded on that page. But I want to see the tracking code when the interaction is emailed to me - so I can neatly track my ads and conversion rate with the bot.

1 Like

I’m not sure if I’ve stumbled upon a bug or a feature but when I combine referral codes and API POSTs everything works perfectly fine till I add the #tarsbot value after the gambit reference in the URL to open the bot in the same tab instead of a new window.

Doesn’t work at all: /?_startgid=45#tarsbot&sku=11L282
Works perfectly fine but open a new window: /?_startgid=45&sku=11L282

Has someone else experienced this or is it just me that is doing something fishy? @vinit maybe you know?

1 Like

Hey @TonyJ,

The #tarsbot needs to be added at the very end of the URL, after any URL params. If you add it before, browser won’t be able to see the URL params coming after it.

So if you use this URL instead:

It should work as expected.

1 Like