【问题标题】:Save Cookie in Transaction ID and use in Shopify thank you page将 Cookie 保存在交易 ID 中并在 Shopify 感谢页面中使用
【发布时间】:2021-05-23 10:46:06
【问题描述】:

我正在寻找将会话 cookie 从登录 URL 保存到 transaction_id 并在感谢页面内的转换像素中使用此 transaction_id 的方法。

登陆 URL 例如。 https://advertiser.myshopify.com/?utm_source=publisher&**transaction_id=102d76ce80070f3f8aa28637124a21**

附加脚本中的转换像素,例如

<img src="https://publisher.com/aff_l?offer_id=1234&currency={{ shop.currency }}&amount={{ line_item.final_line_price | money_without_currency | remove: ',' }}&adv_sub={{ order.order_number }}&adv_sub2={{ customer.orders_count }}&adv_sub3={{ line_item.title }}&adv_sub4={{ line_item.sku }}&adv_sub5={{ line_item.vendor }}&transaction_id={{ transaction_id }}" width="1" height="1" style="position:fixed; left:-100px" />

我在登录页面使用 javascript 来保存交易 ID,如下所示:

var url_string = window.location.href;
var url = new URL(url_string);
var source = url.searchParams.get("utm_source");
var transaction = url.searchParams.get("transaction_id");
if (source == "publisher") {
  localStorage.setItem('utm_source', source);
  localStorage.setItem('transaction_id', transaction);
}

但是,我在感谢页面上的转换像素的结果仍然缺少 transaction_id 值

<img src="https://publisher.com/aff_l?offer_id=1234&currency=MYR&amount=50.00&adv_sub=1180&adv_sub2=160&adv_sub3=Nike Shirt&adv_sub4=SKU0001&adv_sub5=Nike&transaction_id=" width="1" height="1" style="position:fixed; left:-100px">

有没有善良的灵魂能够启发这个迷失的孩子?

感谢您的宝贵时间并感谢!

【问题讨论】:

  • 打开感谢页面后,您可以从 Shopify 后端设置的附加脚本部分检查并运行 JS 代码,但我不是 100% 保存在登录页面上的数据仍然可用于此页面由于 Shopify 安全政策。
  • 我可以在感谢页面找到带有 console.log(transaction_id) 的 transaction_id,但是我应该如何将此值解析为转换像素,以便 {{ transaction_id }} 将捕获此

标签: javascript cookies shopify session-cookies


【解决方案1】:

我认为您需要使用 Javascript 创建相同的元素并将其附加到页面的标题中。但我不确定它是如何由第 3 方读取或工作并发送数据的。 你可以试试,我们希望它对你有用。

var src = 'https://publisher.com/aff_l?offer_id=1234&currency=MYR&amount=50.00&adv_sub=1180&adv_sub2=160&adv_sub3=Nike Shirt&adv_sub4=SKU0001&adv_sub5=Nike&transaction_id='+localStorage.getItem("transaction_id");
var img = document.createElement('img');
    img.src = src;
    img.width = '1';
    img.height = '1';
    img.style.position = 'fixed';
    img.style.left = '-100px';
    document.getElementsByTagName('head')[0].appendChild(img);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-27
    • 2017-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-22
    相关资源
    最近更新 更多