Reputation: 21
I want to implement Facebook Advanced Matching Manually using Google Tag Manager. I did the following:
On GTM, I did the following:
AdvancedMatchingVariable
of the type Data
Layer Variable with Variable Name advancedMatching
<!-- Facebook Pixel Code -->
<script>
...
fbq('init', 'pixel id',
'{{AdvancedMatchingVariable}}'
);
</script>
<!-- End Facebook Pixel Code -->
On my Website, I added this code:
dataLayer.push({
'advancedMatching': {
'em': '$email',
'fn': '$fname',
'ln': '$lname'
}
});
However, It didn't work. I get Object Object in the facebook pixel base code. As the following:
<!-- Facebook Pixel Code -->
<script>
fbq('init', '*ID*',
Object Object
);
</script>
<!-- End Facebook Pixel Code -->
So please what is the problem with my code? I have been searching and trying to fix it for hours!
Upvotes: 0
Views: 591
Reputation: 5208
You just need to modify your pixel code to remove the quotes around like so:
<!-- Facebook Pixel Code -->
<script>
...
fbq('init', 'pixel id',
{{AdvancedMatchingVariable}}
);
</script>
<!-- End Facebook Pixel Code -->
Upvotes: 0
Reputation: 1210
I think you have to parse the values of the advancedMatching
object yourself in the FB pixel, like
fbq('init', 'pixel id', {
em: advancedMatching.em,
fn: advancedMatching.fn,
ln: advancedMatching.ln
});
You could probably write a helper function to map this for you, if you have dynamic tracking parameters in advancedMatching
.
Upvotes: 1