Overwriting clickTag on a Website

When a clickTag is used in a banner project, it can be overwritten with the target URL on the ad server without any problems. So far so good!
Is there a way to overwrite this variable on the website where the banners are published e.g. for the preview as well?
If on the preview website the individual banners could be overwritten with an individual target URL, even though the exact same variable was used in each banner, this would be exactly what I am looking for.
Thanks for your advice and only the best
Urs

Well, there's always a way :slight_smile:.... are you using a particular Export Script? I think advice is probably dependent on that.

If you're not using an export script, do you mind sending a zip of your .hype document along with a sample export that works correctly in the preview environment?

Hello Jonathan
Thanks for your help.
I use the script for "DoubleClick DCM" which I found on the Tumult website. Ev. not in the latest version, but, from my point of view, still helpful.
But my problem I see less in the script.
On an AdServer, the variable "clickTag" can be overwritten with any target URL.

That means, if I want to replace for example the URL https://www.post.ch with the URL https://www.tumult.com, I don't have to do it in my ad media, it will be replaced on the AdServer.
But now I want to be able to replace the variable clickTag on a "normal" website to show the customer how it will work on the AdServer.
For this case, replacing the "var clickTag" I am looking for a solution here.
Thank you again for your help and best regards, Urs

If you use the DoubleClick DCM export script, that will output a clickTag URL as defined in the Document Inspector:

Screenshot 2023-04-11 at 7.17.06 PM

So all you would need is to set that and just export as a DoubleClick DCM ad. You'd need to unzip from the export and distribute that.

As long as you're using the corresponding "Exit" action (as part of the DoubleClick DCM ad) then it will use the clickTag defined in the document inspector.

Does that solve it for you or do you want something more dynamic (like a URL parameter) or that doesn't require you exporting as this ad type?

Thank you Jonathan
To tell the truth, this is not what I am looking for.
So far I haven't used the Document Inspector to set the variable "clickTag".
I use this JavaScript and everything works fine:

<script type="text/javascript">
	var clickTag = "https://www.post.ch/";
</script>

My wish is to be able to replace the variable "clickTag" on the website exactly as it can be done on the AdServer.
That is, if I enter the URL "https://myexit.com" in the ad, it can be replaced with "https://yourexit.com" on the AdServer. But can I do the same on the website?
I am already aware that this has nothing to do with Hype itself and is a handling on the website. However, someone may have a solution to my question.
Thanks a lot and best regards
Urs

Since you are declaring the clickTag in a var already

You may be able to use something like this code to update it to one you want.

In an on scene load Action or a Prepare For Display Action (either should work) run this in a function.

	 console.log("Old clicktag " ,clickTag);
	 
	const urlParams = new URLSearchParams(window.location.search);
	const clicktag_ = urlParams.get('clicktag');
	
	if(clicktag_?.length > 0) {
		clickTag = clicktag_
			console.log("New clicktag " ,clickTag);
		 
	}

Then you change the url in the browser to use a search query.

for example if the url to the hype file was.

https.example.com/myadexample.html

and you wanted to change the clickTag to https://forums.tumult.com/

You would change the url to:

https.example.com/myadexample.html?clicktag=https://forums.tumult.com/

The clickTag var should be changed to https://forums.tumult.com/

3 Likes

That was going to be my suggestion as well!
@grebe, Is this what you had in mind?

2 Likes

Thanks a lot for your code MarkHunte.
As far I understood your hint, there will be a action on the browser needed.
I had the following in mind.
I’m the one producing the Ads. There, I like to put allways the same clickTag-var in. Let’s say https://www.post.ch
I’m also the one, runnig a website to show my customers the Ads for the reason of a preview.
On this website, I like to change the clickTag-var, let’s say to https://tumult.com. So my customer would have the feeling, I implemented the Tumult-URL directly in to the Ad. The customer should only need to click on the Ad to reach the Tumult website.
Maybe my wish is a bit strange, but for me it would be helpful.
Thanks a lot and best regards
Urs

how are the ads implemented in your webpresentation?
iframes, divs, via Hypes wordpress-plugin? oam, zip ... somehow a dynamic import?
can you provide a sample-link?

without very concrete info this'll be hard to solve

anyway ... if the ads are embedded as iframe @MarkHunte 's solution would be an easy way to go ... just change the src as mentioned above.

1 Like

Yes.

This is what is being suggested.

A way for you to give you customers an individual link that will work on a single preview html page on your site.

The code within the hype project will take care of the click tag changes dependent on the url's search param.

I am not an advertising person so do not fully know the ins and out of ad mechanism. So in these examples I use window.location = fooUrl etc in a function to actually open the clicktag urls.


If the ad is as @h_classen says in an iframe then the code would have to take that into account .
( we do not need to change the src )

The example ad here has code that should work on either iframe ad or not.


	 
	 
	  var urlParams = new URLSearchParams(window.location.search);
	  
	 if ( window.self !== window.top )  {
 
 	 	console.log("IS IFRAME");
	  
      urlParams = new URLSearchParams(window.top.location.search);     
  
      }  
    
     
     console.log("OLD clicktag " ,clickTag);       
	 
	
	const clicktag_ = urlParams.get('clicktag');
	
	if(clicktag_?.length > 0) {
		 
 		clickTag = clicktag_
		  
			console.log("New clicktag " ,clickTag);
		 
	}

original clicktag:

https://www.post.ch/

And with the search param ?clicktag=https://forums.tumult.com/ on the end of the page url
it will be updated to:

https://forums.tumult.com/


Normal non iframe page live link

https://markosx.com/hypeTests/clicktag/clickTagChange.html?clicktag=https://forums.tumult.com/


iframed live link ( src is the normal page above )

https://markosx.com/hypeTests/clicktag/examplAdIframe.html?clicktag=https://forums.tumult.com/


There is nothing special about the iframe project. It is just a Rect with iframe code inside with a src and size, so no need to post that.

Here is the actual ad project.

clickTagChange.hypetemplate.zip (919.9 KB)

4 Likes

Thanks h_classen.
The ads are implemented via iframes.
I will try the solution from MarkHunte and give here a feedback.
Best regards

Thank you very much MarkHunte.
So I misunderstood something wrong. I will try your solution and give a feedback here.
Best wishes, Urs

1 Like

Hello MarkHunte
It works perfectly.
Thanks for the tip and your patience.
Best wishes, Urs

3 Likes