Cross-domain Settings

What is cross-domain? #

Cross-domain means that there are two or more different domains in a site, and links to different domains are measured as the same session.
For example: a visit behavior from page "a.com" to page "b.com" is a cross domain.

Cross-domain scenarios #

In what specific situations do you need to set up a cross domain? Let's take a look at the following examples.

  • 1If the product detail page and the payment page of your e-commerce site are on different domains, and you want to measure the users who made a successful payment as a goal, you need to set up a cross-domain.
  • If your product introduction and application pages are on different domains, and you want to measure the behavior of users who fill out the form from the product introduction page, you need to set up a cross domain.

In other words, you need to set up cross-domain so that the session will not be broken when navigating between pages that have different domains.

Prerequisite #

You must be able to move from "a.com" to "b.com" and have the same Ptengine Experience basic set for both "a.com" and "b.com" (please note that base tags are different for each project).

Cross-domain Settings #

Now, let's take a look at the specific cross-domain settings.
There are three ways to set it up: automatic, manual (for <a> links) and manual (for non-<a> links), and you can set it up according to your needs.

Note: Please note that if undefined parameters are added to the cross-domain destination, you may be redirected to an error page. For example, there are cases where payment pages restrict the addition of parameters for security reasons.

  • 1Automatic Settings
    As shown in the image, select "Data Settings" in the project settings, and click "Tracking Code Instruction", and turn on the switch to complete the settings.

    After switch on the settings, the cross-domain identifier "_pt_link=***********" will be automatically assigned to all link URLs on the page which direct to a different domain. Please Note that the URL length need to be 900 characters or less. For details, please refer to the following example.

  • Before: <a href="https://www.b.com"></a>
    After: <a href="https://www.b.com#_pt_link=_s_gEjf3wNa5RNxgw4lC5H8Eg..."></a>

Note:
Please note that turning on the switch will apply to both Ptengine Insight and Ptengine Experience (turning on the switch will disable the original cross-domain tags set in Ptengine Insight).
If you do not turn on the switch, you can continue to use the original cross-domain tags set in Ptengine Insight (the original cross-domain tags set in Ptengine Insight are applied only in Ptengine Insight).

  • 2Manual Settings - for <a> link
    Add the customer property "data-pt-crossDomain" to the <a> link where you want to set the cross domain, and you are all set.

    After this, the cross-domain identifier "_pt_link=***********" will be automatically assigned to all link URLs on the page which direct to a different domain. Please Note that the URL length need to be 900 characters or less. For details, please refer to the following example.

  • Example: If you want to go from "a.com" to "b.com", add "data-pt-crossDomain" to the <a> link that goes to b on page a.
    What you set: <a href="https://www.b.com" data-pt-crossDomain>button</a>
    After you set: <a href="https://www.b.com#_pt_link=_s_gEjf3wNa5RNxgw4lC5H8Eg...">button</a>

  • 3Manual Settings - for non-<a>link
    Set up Ptengine's external integration API below in the JavaScript of the button click event, and you are done.

    API:window.ptengine.createCrossDomainUrl

    For example, if you want to navigate to another site by clicking a button, you can set it up by using Ptengine's external integration API as shown below.

var btn = document.querySelector(".btn");
btn.addEventListener("click", function(){
    var targetUrl = 'https://www.b.com';
    var openUrl = window.ptengine && window.ptengine.createCrossDomainUrl && typeof window.ptengine.createCrossDomainUrl === 'function' && window.ptengine.createCrossDomainUrl(targetUrl); 
    window.open(openUrl)
},false)

Was this article helpful?

  • Yes, great!
  • Not really

Thanks for your feedback.

  Sorry about that. Do you mind sharing how we can improve?

    Write your feedback here...