I have multiple Facebook Pixels ID that will be passed as URL parameters (i.e. first pixel 'fbpid=123456789' - second pixel 'fbpid=987654321' etc.)
我有多个Facebook Pixels ID将作为URL参数传递(即第一个像素'fbpid = 123456789' - 第二个像素'fbpid = 987654321'等)
Whenever a user clicks a certain button, if the URL parameter is 'fbpid=12345679', then only the pixel ID 123456789 should be fired.
每当用户单击某个按钮时,如果URL参数为'fbpid = 12345679',则只应触发像素ID 123456789。
Instead, if the pixel ID in the URL parameter is 'fbpid=987654321' then only the pixel with the ID 987654321 should be fired, and so on.
相反,如果URL参数中的像素ID为'fbpid = 987654321',则应仅触发ID为987654321的像素,依此类推。
How could I retrieve the URL parameter in GTM and fire just the Facebook pixel ID passed as URL parameter?
如何在GTM中检索URL参数并仅触发作为URL参数传递的Facebook像素ID?
2 个解决方案
#1
0
Go to variables, custom variables, new, select "URL" as variable type, "query" as component type and "fbpid" as query key. This will return the value for fbpid if the query parameter is present in the url.
转到变量,自定义变量,新建,选择“URL”作为变量类型,“查询”作为组件类型,“fbpid”作为查询键。如果查询参数存在于url中,这将返回fbpid的值。
You can then use the value in a trigger (i.e. create a pageload trigger, fire on some events, condition fbpid equals 123456789).
然后,您可以在触发器中使用该值(即,创建页面加载触发器,触发某些事件,条件fbpid等于123456789)。
#2
0
Thanks a lot for your answer.
非常感谢您的回答。
Here's how the entire pixel script looks like:
以下是整个像素脚本的样子:
`<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', 'PIXEL_ID');
fbq('track', 'PageView');
fbq('track', 'Lead');
</script>`
Would it be possible to replace just the "PIXEL_ID" inside the script above with the 'fbpid' passed as a query?
是否可以仅使用作为查询传递的'fbpid'替换上面脚本中的“PIXEL_ID”?
#1
0
Go to variables, custom variables, new, select "URL" as variable type, "query" as component type and "fbpid" as query key. This will return the value for fbpid if the query parameter is present in the url.
转到变量,自定义变量,新建,选择“URL”作为变量类型,“查询”作为组件类型,“fbpid”作为查询键。如果查询参数存在于url中,这将返回fbpid的值。
You can then use the value in a trigger (i.e. create a pageload trigger, fire on some events, condition fbpid equals 123456789).
然后,您可以在触发器中使用该值(即,创建页面加载触发器,触发某些事件,条件fbpid等于123456789)。
#2
0
Thanks a lot for your answer.
非常感谢您的回答。
Here's how the entire pixel script looks like:
以下是整个像素脚本的样子:
`<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', 'PIXEL_ID');
fbq('track', 'PageView');
fbq('track', 'Lead');
</script>`
Would it be possible to replace just the "PIXEL_ID" inside the script above with the 'fbpid' passed as a query?
是否可以仅使用作为查询传递的'fbpid'替换上面脚本中的“PIXEL_ID”?